# Color roles

Text, surface and line roles with one value for light and one for dark.

- ID: tokens/color-roles
- Type: tokens
- Canonical: /reference/tokens/color-roles
- Version: 2.1.8
- Source revision: 09fc2350ea80ed137ba7ca62c8e5926744b5a5dc (revision)
- Source: packages/preset/src/theme.css
- Content digest: 2f3c8231088c4effad4434216b12243d4d37f862b48c3a692d2791fac109e757
- Semantic digest: 83962260d6d56817dd052d2beebf7999a75804215dac050c47b26353145c099a
- Language: en

<a id="consumers"></a>

## Classes

| Class | Property | Declarations |
| --- | --- | --- |
| [`fg-text-<name>`](/reference/tokens/families#family-fg) | `color` | `color: var(--color-text-<name>)` |
| [`bg-surface-<name>`](/reference/tokens/families#family-bg) | `background-color` | `background-color: var(--color-surface-<name>)` |
| [`b-line-<name>`](/reference/tokens/families#family-b) | `border-color` | `border-color: var(--color-line-<name>)` |
| [`b-<role>-<name>`](/reference/tokens/families#family-b) | `border-color` | `border-color: var(--color-<role>-<name>)` |
| [`bb-<role>-<name>`](/reference/tokens/families#family-bb) | `border-bottom-color` | `border-bottom-color: var(--color-<role>-<name>)` |
| [`bg-<role>-<name>`](/reference/tokens/families#family-bg) | `background-color` | `background-color: var(--color-<role>-<name>)` |
| [`bl-<role>-<name>`](/reference/tokens/families#family-bl) | `border-left-color` | `border-left-color: var(--color-<role>-<name>)` |
| [`br-<role>-<name>`](/reference/tokens/families#family-br) | `border-right-color` | `border-right-color: var(--color-<role>-<name>)` |
| [`bt-<role>-<name>`](/reference/tokens/families#family-bt) | `border-top-color` | `border-top-color: var(--color-<role>-<name>)` |
| [`bx-<role>-<name>`](/reference/tokens/families#family-bx) | `border-inline-color` | `border-inline-color: var(--color-<role>-<name>)` |
| [`by-<role>-<name>`](/reference/tokens/families#family-by) | `border-block-color` | `border-block-color: var(--color-<role>-<name>)` |
| [`fg-<role>-<name>`](/reference/tokens/families#family-fg) | `color` | `color: var(--color-<role>-<name>)` |
| [`bxe-<role>-<name>`](/reference/tokens/families#family-bxe) | `border-inline-end-color` | `border-inline-end-color: var(--color-<role>-<name>)` |
| [`bxs-<role>-<name>`](/reference/tokens/families#family-bxs) | `border-inline-start-color` | `border-inline-start-color: var(--color-<role>-<name>)` |
| [`bye-<role>-<name>`](/reference/tokens/families#family-bye) | `border-block-end-color` | `border-block-end-color: var(--color-<role>-<name>)` |
| [`bys-<role>-<name>`](/reference/tokens/families#family-bys) | `border-block-start-color` | `border-block-start-color: var(--color-<role>-<name>)` |
| [`fill-<role>-<name>`](/reference/tokens/families#family-fill) | `fill` | `fill: var(--color-<role>-<name>)` |
| [`caret-<role>-<name>`](/reference/tokens/families#family-caret) | `caret-color` | `caret-color: var(--color-<role>-<name>)` |
| [`accent-<role>-<name>`](/reference/tokens/families#family-accent) | `accent-color` | `accent-color: var(--color-<role>-<name>)` |
| [`stroke-<role>-<name>`](/reference/tokens/families#family-stroke) | `stroke` | `stroke: var(--color-<role>-<name>)` |
| [`outline-<role>-<name>`](/reference/tokens/families#family-outline) | `outline-color` | `outline-color: var(--color-<role>-<name>)` |
| [`text-fill-color-<role>-<name>`](/reference/tokens/families#family-text-fill-color) | `-webkit-text-fill-color` | `-webkit-text-fill-color: var(--color-<role>-<name>)` |

A role is part of the color key: `fg-text-muted` reads `--color-text-muted` through the color namespace. Every color family accepts role keys, including `bg-text-link` and `outline-line-control`; the role name does not restrict the property.

<a id="values"></a>

## Values

Light and Dark are the two arguments of each preset light-dark() value. They are selected by the element’s used color scheme, not by the class prefix or the operating system alone.

<a id="color-text"></a>

### Text

| Class | Variable | Value |
| --- | --- | --- |
| `fg-text-body` | `--color-text-body` | `light-dark(var(--color-zinc-70), var(--color-zinc-30))` |
| `fg-text-strong` | `--color-text-strong` | `light-dark(var(--color-zinc-100), var(--color-white))` |
| `fg-text-muted` | `--color-text-muted` | `light-dark(var(--color-zinc-60), var(--color-zinc-40))` |
| `fg-text-disabled` | `--color-text-disabled` | `light-dark(var(--color-zinc-40), var(--color-zinc-60))` |
| `fg-text-inverse` | `--color-text-inverse` | `light-dark(var(--color-white), var(--color-black))` |
| `fg-text-link` | `--color-text-link` | `light-dark(var(--color-blue-60), var(--color-blue-30))` |
| `fg-text-link-hover` | `--color-text-link-hover` | `light-dark(var(--color-blue-70), var(--color-blue-20))` |
| `fg-text-stone` | `--color-text-stone` | `light-dark(var(--color-stone-60), var(--color-stone-30))` |
| `fg-text-gray` | `--color-text-gray` | `light-dark(var(--color-gray-60), var(--color-gray-30))` |
| `fg-text-zinc` | `--color-text-zinc` | `light-dark(var(--color-zinc-60), var(--color-zinc-30))` |
| `fg-text-neutral` | `--color-text-neutral` | `light-dark(var(--color-neutral-60), var(--color-neutral-30))` |
| `fg-text-slate` | `--color-text-slate` | `light-dark(var(--color-slate-60), var(--color-slate-30))` |
| `fg-text-brown` | `--color-text-brown` | `light-dark(var(--color-brown-60), var(--color-brown-30))` |
| `fg-text-orange` | `--color-text-orange` | `light-dark(var(--color-orange-70), var(--color-orange-30))` |
| `fg-text-amber` | `--color-text-amber` | `light-dark(var(--color-amber-80), var(--color-amber-40))` |
| `fg-text-yellow` | `--color-text-yellow` | `light-dark(var(--color-yellow-90), var(--color-yellow-40))` |
| `fg-text-lime` | `--color-text-lime` | `light-dark(var(--color-lime-80), var(--color-lime-40))` |
| `fg-text-green` | `--color-text-green` | `light-dark(var(--color-green-80), var(--color-green-40))` |
| `fg-text-beryl` | `--color-text-beryl` | `light-dark(var(--color-beryl-90), var(--color-beryl-40))` |
| `fg-text-teal` | `--color-text-teal` | `light-dark(var(--color-teal-90), var(--color-teal-40))` |
| `fg-text-cyan` | `--color-text-cyan` | `light-dark(var(--color-cyan-90), var(--color-cyan-40))` |
| `fg-text-sky` | `--color-text-sky` | `light-dark(var(--color-sky-70), var(--color-sky-30))` |
| `fg-text-blue` | `--color-text-blue` | `light-dark(var(--color-blue-60), var(--color-blue-30))` |
| `fg-text-indigo` | `--color-text-indigo` | `light-dark(var(--color-indigo-60), var(--color-indigo-30))` |
| `fg-text-violet` | `--color-text-violet` | `light-dark(var(--color-violet-60), var(--color-violet-30))` |
| `fg-text-purple` | `--color-text-purple` | `light-dark(var(--color-purple-60), var(--color-purple-30))` |
| `fg-text-fuchsia` | `--color-text-fuchsia` | `light-dark(var(--color-fuchsia-70), var(--color-fuchsia-30))` |
| `fg-text-pink` | `--color-text-pink` | `light-dark(var(--color-pink-80), var(--color-pink-30))` |
| `fg-text-crimson` | `--color-text-crimson` | `light-dark(var(--color-crimson-80), var(--color-crimson-30))` |
| `fg-text-red` | `--color-text-red` | `light-dark(var(--color-red-80), var(--color-red-30))` |

<a id="color-surface"></a>

### Surface

| Class | Variable | Value |
| --- | --- | --- |
| `bg-surface-base` | `--color-surface-base` | `light-dark(var(--color-zinc-0), var(--color-zinc-95))` |
| `bg-surface-inset` | `--color-surface-inset` | `light-dark(var(--color-zinc-5), var(--color-zinc-100))` |
| `bg-surface-raised` | `--color-surface-raised` | `light-dark(var(--color-white), var(--color-zinc-90))` |
| `bg-surface-floating` | `--color-surface-floating` | `light-dark(var(--color-white), var(--color-zinc-80))` |
| `bg-surface-inverse` | `--color-surface-inverse` | `light-dark(var(--color-black), var(--color-white))` |

<a id="color-line"></a>

### Line

| Class | Variable | Value |
| --- | --- | --- |
| `b-line-divider` | `--color-line-divider` | `light-dark(oklch(0% 0 none / .12), oklch(100% 0 none / .12))` |
| `b-line-control` | `--color-line-control` | `light-dark(var(--color-zinc-50), var(--color-zinc-40))` |
| `b-line-subtle` | `--color-line-subtle` | `light-dark(oklch(0% 0 none / .06), oklch(100% 0 none / .06))` |

<a id="color-scheme"></a>

## The local color scheme selects the value

`fg-text-muted` emits `color: var(--color-text-muted)`. Its preset value uses `light-dark(var(--color-zinc-60), var(--color-zinc-40))`: light selects the first color, dark the second. The class and generated rule stay the same.

**One role, two local color schemes**

The used color scheme selects the first or second color. Both specimens keep fg-text-muted and bg-surface-base; the local scheme changes their computed colors.

- fg-text-muted generates color: var(--color-text-muted). Its preset token contains light-dark(var(--color-zinc-60), var(--color-zinc-40)).
- The light specimen uses the first argument, --color-zinc-60. The dark specimen uses the second, --color-zinc-40.
- Both specimens use bg-surface-base and the same text class. The colored leaders identify the two arguments; they are annotations, not the resulting text colors.
- The local used color scheme selects the branch. The comparison does not imply that system media queries follow a manual local theme.

The preset enables `color-scheme: light dark` on the root. Its `data-theme="light"` and `data-theme="dark"` selectors can choose a scheme on the root, a nested region or a shadow host. Native CSS performs the selection; switching schemes does not require regenerating this utility.

The `@dark` and `@light` class suffixes test the system preference. A manual `data-theme` choice does not activate those media queries. Use the mode contract for selector-based conditions.

A role supplies a color, not a component or a contrast guarantee for every background. Inverse surfaces have a paired inverse text role. Divider and subtle lines are decorative; control lines identify boundaries. Recheck the actual pair when changing a surface, opacity or token value.

See [Variables and modes](/reference/rules/modes#mode-triggers) and [native light-dark() selection](https://www.w3.org/TR/css-color-5/#light-dark).

<a id="usage"></a>

## Usage

Build a card from roles: a raised surface, a divider line, and strong, body and muted text.

```html
<article class="… b(1) b-solid b-line-divider bg-surface-raised">
  <h3 class="… fg-text-strong">Make space for ideas</h3>
  <p class="… fg-text-body">A steady rhythm keeps the focus on the content.</p>
  <p class="… bt(1) bt-solid bt-line-divider fg-text-muted">4 min read</p>
</article>
```

```css disclosure=generated-css
@layer theme{:root,:host{--color-zinc-30:oklch(78% .0025 265);--color-zinc-40:oklch(68.6% .0028 265);--color-zinc-60:oklch(48.6% .003 265);--color-zinc-70:oklch(39.8% .0028 265);--color-zinc-90:oklch(24.6% .0022 265);--color-zinc-100:oklch(15% .0016 265)}:root,:host{--color-surface-raised:light-dark(var(--color-white), var(--color-zinc-90));--color-line-divider:light-dark(oklch(0% 0 none / .12), oklch(100% 0 none / .12));--color-text-body:light-dark(var(--color-zinc-70), var(--color-zinc-30));--color-text-strong:light-dark(var(--color-zinc-100), var(--color-white));--color-text-muted:light-dark(var(--color-zinc-60), var(--color-zinc-40))}:root,:host{--color-white:oklch(100% 0 none)}}@layer utilities{.bg-surface-raised{background-color:var(--color-surface-raised)}.b-line-divider{border-color:var(--color-line-divider)}.bt-line-divider{border-top-color:var(--color-line-divider)}.b-solid{border-style:solid}.bt-solid{border-top-style:solid}.b\(1\){border-width:calc(1 * 1px)}.bt\(1\){border-top-width:calc(1 * 1px)}.fg-text-body{color:var(--color-text-body)}.fg-text-muted{color:var(--color-text-muted)}.fg-text-strong{color:var(--color-text-strong)}}
```

<a id="customize"></a>

## Customize

Add a role with one value per color scheme: `--color-text-brand` creates `fg-text-brand`.

```css
@theme {
  --color-text-brand: light-dark(
    var(--color-indigo-60),
    var(--color-indigo-30)
  );
}
```

```css disclosure=generated-css
@layer theme{:root,:host{--color-indigo-30:oklch(70.2% .1611 282.9);--color-indigo-60:oklch(50.06% .2906 282)}:root,:host{--color-text-brand:light-dark(var(--color-indigo-60), var(--color-indigo-30))}}@layer utilities{.fg-text-brand{color:var(--color-text-brand)}}
```

See [theme directives](/reference/directives/theme) and [Color](/guide/colors#choose-a-color-token).

## Related reference

- [rules/modes](/reference/rules/modes.md)
- [directives/theme](/reference/directives/theme.md)
