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:
- a variant’s
elements - a composition’s
elements - a slot content fill
- a subcomponent’s elements
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 names | Why that spelling | |
|---|---|---|
| Key | A token group, verbatim | It must match the group segment of the $token paths the selection governs |
| Value | One of that group’s themes, verbatim | The token source owns the theme vocabulary |
themes: DE Color: Dark DE Space: CompactNeither 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: CompactdecorativeIcon 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: Darkvariants: - configuration: { appearance: Plain } elements: panel: themes: DE Color: nullUnder 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
| Rule | Consequence |
|---|---|
| An absent key means inherit, not default | An 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 written | DE 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 recorded | The 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
| Limit | Detail |
|---|---|
| A value is never a binding | A 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 locked | Any 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 strings | A 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.
| Platform | What a selection becomes |
|---|---|
| CSS | The scope of the stylesheet’s theme override block, set on the selecting element rather than the document root |
| React | An attribute on the selecting element; the root’s is settable on the instance, with the authored selection as its default |
| Web Components | The same attribute, same contract |
| Figma | A 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
themessits 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