Skip to content

Themes

A design token does not carry one value. DE Color/Surface/Primary resolves to one colour under one theme and another colour under a second, and which theme applies is a fact of the element rather than of the token. themes is where an element states the theme in force for itself and everything beneath it.

type Themes = Record<string, string | null>;

It sits on Element, beside styles, so it reaches every place elements appear:

Keys and values

A token reference path leads with the group the token belongs to — DE Color in DE Color/Surface/Primary. A group defines the themes its tokens resolve under, and a themes entry selects one of them.

What it namesWhy that spelling
KeyA token group, verbatimIt must match the group segment of the $token paths the selection governs
ValueOne of that group’s themes, verbatimThe token source owns the theme vocabulary
themes:
DE Color: Dark
DE Space: Compact

Neither is formatted to spec.keys, which governs anatomy keys, prop keys and references to them. A token group is none of those: it is already verbatim everywhere else it appears in a spec, leading a $token path.

The map shape allows one key per group, so a group cannot be selected twice on one element.

Inheritance

A key is written only on the element that selects the theme. Nothing copies the effective selection onto descendants, so the written facts are the authored facts.

default:
elements:
root:
themes:
DE Color: Dark
styles:
backgroundColor: { $token: "DE Color/Surface/Primary", $type: color }
decorativeIcon:
styles:
fillColor: { $token: "DE Color/Alert/Info/Element", $type: color }
variants:
- configuration: { appearance: Warning }
elements:
root:
themes:
DE Color: Dark
DE Space: Compact

decorativeIcon carries no themes key, so its fill resolves under root’s Dark selection. A descendant that selects the same group overrides it for its own subtree, and selections layer across variants like any other element property (Variants).

Removing a selection

A value may be null, which selects nothing for that group. It is how a layering variant takes back a selection the default variant made:

default:
elements:
panel:
themes:
DE Color: Dark
variants:
- configuration: { appearance: Plain }
elements:
panel:
themes:
DE Color: null

Under appearance: Plain the panel selects nothing, so its subtree resolves against whatever encloses it again.

This is the distinction null already draws in a prop configuration: an absent key inherits from the layer beneath, where a null key overrides the inherited value with no value. Every element selects nothing for every group until something says otherwise, so null is that baseline written down rather than a new state.

A consumer resolving selections drops the key on null rather than carrying it — carrying it would read as selected-to-nothing instead of unselected. On the web that falls out for free: no attribute is emitted, so the stylesheet’s block stops matching. On the canvas the render clears the mode the node carried.

Rules

RuleConsequence
An absent key means inherit, not defaultAn element’s effective themes are its own keys merged over its ancestors’, through nested instance boundaries, nearest selection winning. Unlike an absent style key, there is no declared default at this site
A selection equal to the group’s default theme is writtenDE Color: Light on a group whose default theme is Light holds light inside a dark ancestor, where an absent key would inherit the dark
A selection made above the component is not recordedThe theme a component was authored within is the context it was captured in, not part of its design, so a consumer supplies that context itself

Limits

LimitDetail
A value is never a bindingA selection cannot vary with a prop. The map shape admits that widening later without a reshape, the way content and styles.visible already accept a PropBinding
A selection is never lockedAny ancestor or descendant overrides it, so a component that holds one theme against every ambient context is not expressible with this alone
Names are unvalidated stringsA misspelled group or theme passes schema validation and fails when something tries to resolve it

Platforms

Every target has its own mechanism for scoping a theme to part of a tree, and a themes entry is what each one reads.

PlatformWhat a selection becomes
CSSThe scope of the stylesheet’s theme override block, set on the selecting element rather than the document root
ReactAn attribute on the selecting element; the root’s is settable on the instance, with the authored selection as its default
Web ComponentsThe same attribute, same contract
FigmaA variable collection mode re-applied to the node, so the subtree resolves as authored

Provenance

In a Figma-sourced spec a token group is a variable collection and a theme is one of its modes. That mapping is provenance, like the collectionName a token reference records under $extensions['com.figma'] — a themes entry itself names neither, and no consumer needs the Figma reading to resolve one.

See Also

  • Elements — the type themes sits on
  • Token Reference — what a selection changes the resolution of
  • Variants — how a selection layers across variants
  • spec.keys — the key formatting a token group is exempt from