Codex

Codex is the design system for Wikimedia. To learn more, visit the official documentation site. This page covers the Codex software package.

The Codex software package includes design tokens to store design values, user interface components built in JavaScript (Vue.js) and only with CSS, and a suite of icons. These tools include wide-ranging support for internationalization, global usage and web accessibility by default.

This page documents how to use Codex in MediaWiki. You may also want to read the more general documentation about how to use Vue.js in MediaWiki.

Current version
MediaWiki currently uses version 0.8.0 of Codex. New versions are released every 2 weeks (see the Release Timeline for release cadence and all versions).

Packages
The following Codex packages are available in MediaWiki:


 * : This package contains design tokens in various formats, including Less variables and JSON.
 * : This package contains UI components built with Vue 3 or as CSS-only components.
 * : This package contains a set of icons.

Read below to learn how to use these packages in MediaWiki.

Differences between Codex documentation and MediaWiki usage
The Codex documentation includes code examples that show how to use each component. These examples will not work in MediaWiki, because they use /, TypeScript types, and self-closing tags. The table below summarizes the differences between what is shown in the Codex documentation, and what must be used instead in MediaWiki. Also read the section on this page that go into more detail about how to use Codex design tokens, components, and icons in MediaWiki.

Using your local version of Codex in your local MediaWiki instance
Sometimes it can be helpful to use your local version of Codex in your local MediaWiki instance, in order to test new features or changes in Codex that have not yet been released and included in MediaWiki core. We hope to eventually automate this, but until we have that capability, you can do this manually by copying the dist files from the Codex packages into `resources/lib` in core.


 * 1) Build your local Codex library by running   in the root of your Codex repository.
 * 2) Copy the parts of Codex that you need into your MediaWiki core repository. All of the examples below assume that you use a Unix-like system (e.g. Linux or macOS), your Codex repo and your core repo live in the same directory, and that you are working from the core directory:
 * 3) To copy the   package, which contains Codex components:
 * 4) To copy the   package:
 * 5) To copy the   package:

Using Codex design tokens
Design tokens are the smallest stylistic pieces of our design system. Learn about Codex design tokens in the official documentation and see demos of available tokens (for example color tokens demo).

Benefits of using design tokens
All visual aspects of the design system, such as colors, typography, spacing, and sizes are defined with tokens. They provide a central source of truth for these design elements, which can then be used across multiple platforms and applications, here MediaWiki skins and extensions. By using design tokens, designers and developers can ensure consistency in the look and feel of their digital products. For example, instead of hard-coding a specific color value in multiple places within a website or app, a design token for that color can be created and used throughout the system. In the final stage of tokens architecture, all Codex tokens should be used exclusively for style properties in MediaWiki core, skins and extensions. A change like a color replacement will be easily reflected everywhere.

Design tokens help streamline the design and development process, increase efficiency, and maintain visual consistency throughout a project.

Using Codex design tokens in MediaWiki and extensions
You can import the design tokens directly into your Less file or  block via relying on mediawiki.skin.variables.less import. We use MediaWiki's skin variables system to distribute Codex tokens.

The underlying ResourceLoader functionality accompanies and partly replaces skinStyles definitions as the variable values differ per skin. The tokens are currently providing default Codex theme in MinervaNeue and a modification for smaller base font in Vector 2022 and Vector legacy. The files are located in  and. All other skins are currently receiving fallback values, which is still undergoing development. Example on how to import the Less variables version of the tokens into a MediaWiki extension.

Getting started
See the official docs to learn more about the available Vue 3 components, including demos and usage information (for example, see the Button component demo). Note that code samples from these demos will not work in MediaWiki—see below for more information.

Using Codex components in MediaWiki and extensions
Codex is included in MediaWiki, and is made available through the  ResourceLoader module. To use Codex components in your code, add  to your module's dependencies, then import the components you need as follows: You can then pass these components to the   option of your component, and use them in your component's template. Remember that kebab-case is required in templates, so you have to use  for CdxButton,   for CdxTextInput, etc.

Example
Example of a simple block form using the CdxButton and CdxTextInput components from Codex: Example of the module definition (in  format):

Getting started
Visit the official docs site for information about the icon system and a list of all icons.

Using Codex icons in MediaWiki and extensions
For performance reasons, there is no  ResourceLoader module containing all the icons from Codex. Such a module would be large and wasteful, since most users of Codex only need a handful of the 200+ icons. Instead, ResourceLoader provides a way for modules to embed the icons they need, by defining a package file as follows: These icons can then be imported in  files as follows: For more information about how to use these icons once you've imported them, see the Codex documentation on icons.

Example
Example of the same block form as above, but with an icon added:

Example of the ResourceLoader module definition: In this example,  is an init file that mounts the component with , as documented here.

Codex Release Cadence
A new version of Codex is released every other Tuesday. On the day the new release is created, we also submit a patch to MediaWiki core to use that new release. Since we do this on Tuesdays, the update to core will be deployed the following week (the next time the deployment train runs). You can view all Codex tags on Gerrit or a tag timeline on GitHub. For more information about what is contained in each release, see the changelog.


 * Last release: 2023-02-14
 * Next release: 2023-02-28

See also: Design Systems Team/Release Timeline

Where to find the latest version of Codex
The official docs site is now based on the latest release of Codex (which is the one in MediaWiki core).