> To build a Wix site agentically, or add Wix features like bookings or a store to a site you already have, follow https://www.wix.com/headless/skill.md
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Contributing Tokens

## Article: Contributing Tokens

## Article Link: https://dev.wix.com/docs/wix-design-system/contributing/contributing-tokens.md

## Article Content:

<!-- heading -->

# Tokens

<!-- end heading -->

<br />

> Design Tokens are defined by our Designers, with the source of truth located in Figma. This guide serves as a bridge between Figma and Components, transforming Figma variables into meaningful outputs.

---

## Reading Tokens

1. To effectively read Wix Design System tokens, you need access to our [Figma spec](https://www.figma.com/design/bRlVvOFfXF2oNMt8KEzXN0/WIP---Wix-Design-System-Library?m=auto&t=6JBv4VQBjyIVwDhB-6).
2. To read the tokens from the Figma spec, you need either:
   - **Dev mode** (recommended)
   - **Edit rights**

### Dev Mode

1. Enter Dev Mode by pressing `Shift+D` (Mac) or clicking the Dev Mode toggle button in the UI. If you have trouble entering Dev Mode, refer to [this guide](https://help.figma.com/hc/en-us/articles/15023124644247-Guide-to-Dev-Mode).
2. Navigate to the `Plugins` tab.
3. Search for the Token Lab plugin and install it.
4. Use the Token Lab plugin to export tokens. This will output the tokens in JSON format.

After completing these steps, you will have a JSON file with all the WDS tokens in the Token Lab format. This file is divided by token levels (`Foundation`, `Semantic`, and `Component`) and themes (`wds`, `studio`, and `wixel`).

<!-- grid layout -->

<!-- grid layout item -->

<!-- grid layout content -->

```json
{
  // 00-foundation-wds.json
  {...}
  // 00-foundation-wix-studio.json
  {...}
  // 00-foundation-wixel.json
  {...}
  // 01-semantic-tokens-wds.json
  {...}
  // 01-semantic-tokens-wix-studio.json
  {...}
  // 01-semantic-tokens-wixel.json
  {...}
  // 02-component-tokens-wds.json
  {...}
  // 02-component-tokens-wix-studio.json
  {...}
  // 02-component-tokens-wixel.json
  {...}
}
```

<!-- end grid layout -->

<!-- end grid layout item -->

<!-- end grid layout content -->

---

## Writing Tokens

Tokens are stored in the `src/tokens` directory, organized similarly to Token Lab tokens by theme (`default (wds)`, `studio`, `odeditor`, `odeditor-dark`, and `studio2-light`) and by level (`foundation`, `semantic`, and `component`). Note that the Token Lab output isn't compatible with the [Style Dictionary](https://amzn.github.io/style-dictionary/#/) format, so you can't use it directly as a source for Style Dictionary.

### Updating Style Dictionary JSON

Since Token Lab output isn't directly compatible with the format that Style Dictionary uses, you need to either:

- Extract and add values manually (recommended for small changes)
- Process Token Lab output and insert it into the Style Dictionary JSON (recommended for large changes)

#### Extract and add values manually

For small updates, it's usually quicker to do this manually. Create new entries in the appropriate `.json` files for the relevant level and theme based on the Token Lab output.

Here's how to do this:

1. In Figma, you receive a variable name like `color.text.primary`.
2. Identify that this is a `foundation` token. You can determine this from Figma, as every variable belongs to one of these categories: `foundation`, `semantic`, or `component`.
3. Navigate to `packages/wix-design-system-tokens/src/tokens/INSERT_THEME_NAME/foundation.json`.
4. Find the `color` object and check for a nested object called `text`. If it doesn't exist, create it along with another nested object for the `primary` key. So it will result in `color.text.primary` objects sequence.
5. Repeat this process for all relevant themes.

#### Process output and insert

For larger numbers of tokens, adding them manually can be tedious. Our `figma-to-dictionary` script can help by sanitizing and transforming Token Lab output to match the format used by Style Dictionary. Here's how to use `figma-to-dictionary`:

1. Create a `figma-to-dictionary/input.json` file.
2. Copy the tokens you want to add from the Token Lab output into `input.json`.
3. Run the script:
<!-- grid layout -->

<!-- grid layout item -->

<!-- grid layout content -->

```bash
pnpm figma-to-dictionary
```

<!-- end grid layout -->

<!-- end grid layout item -->

<!-- end grid layout content -->

This creates a `figma-to-dictionary/output.json` file with processed tokens.

4. Copy tokens from `figma-to-dictionary/output.json` and insert them into the respective `.json` file in the `src/tokens` directory.
   - _BEWARE: There might be incorrectly exported tokens, as this script isn't waterproof, so manual adjustments may be necessary._

### Generating Style Dictionary Output (CSS variables)

Once the `.json` files are updated, you can generate the new Style Dictionary output. To do this, first navigate to `packages/wix-design-system-tokens` and run:

<!-- grid layout -->

<!-- grid layout item -->

<!-- grid layout content -->

```bash
pnpm generate && pnpm build
```

<!-- end grid layout -->

<!-- end grid layout item -->

<!-- end grid layout content -->

Then, navigate back to the main entry of monorepo folder and run:

<!-- grid layout -->

<!-- grid layout item -->

<!-- grid layout content -->

```bash
pnpm install
```

<!-- end grid layout -->

<!-- end grid layout item -->

<!-- end grid layout content -->

This script creates all the output files like `.css` and `.st.css`, which are later used in components.

<br>
<br>
<br>
<br>
<br>