Design Systems
Variables and modes
A variable is a named value: a color, a number, a text or a switch. A layer's fill, radius, gap or font size can follow a variable in place of holding a value of its own. Change the variable and everything that follows it changes. Give the variable a value for each mode, and one design is light and dark, compact and roomy, English and German.

Sets and modes#
Variables live in sets. A set has modes of its own, as many as you name: a set Theme with Light and Dark, a set Density with Regular and Compact. The first mode is the default. Every variable in the set has a value for each mode.
Name variables with / between their groups: color/bg/page, color/text/primary, space/md. Name them for their role, not their value: color/accent, not blue-500. A role survives a rebrand.
- Open Variables on the rail. The plus makes a color, a number, a text or a switch.
- Use the set's menu at the top for New Set…, and the mode's menu for New Mode…. A new mode starts with the values each variable holds now.
- Choose All Modes… to see and edit every mode side by side.

Create a Theme set with Light and Dark modes: page and card backgrounds, primary and secondary text, a border, an accent, plus radius/card 16 and space/md 16.
The agent calls set_variables, which makes or changes many variables in one step:
{
"set": "Theme",
"modes": ["Light", "Dark"],
"variables": [
{"name": "color/bg/page", "values": {"Light": "#F4F5F8", "Dark": "#14161B"}},
{"name": "color/bg/card", "values": {"Light": "#FFFFFF", "Dark": "#1E2128"}},
{"name": "color/text/primary", "values": {"Light": "#111318", "Dark": "#F2F4F7"}},
{"name": "color/text/secondary", "values": {"Light": "#6B7280", "Dark": "#9AA3B5"}},
{"name": "color/border", "values": {"Light": "#E3E6EC", "Dark": "#2C303A"}},
{"name": "color/accent", "values": {"Light": "#2F6BFF", "Dark": "#6E9BFF"}},
{"name": "color/link", "values": {"variable": "color/accent"}},
{"name": "radius/card", "values": 16},
{"name": "space/md", "values": 16}
]
}
One value alone is for the default mode, and the other modes have the same. {"variable": "color/accent"} makes a variable follow another, in every mode.
Binding layers to variables#
By hand:
- A color. Click a fill's or a stroke's swatch. Under Variables in the color picker, choose one.
- A number. Right-click a field (W, H, opacity, radius, stroke width, gap, padding, the size limits, a text's size, line height and spacing, an effect's numbers) and choose Follow a Variable. Or type
=and the name into the field, such as=space/md. - A text's words or font. Open Type Details on a text; under Follows a Variable, choose one for Words or Font.
A field that follows shows the variable's name as a tag. Stop Following leaves the value as it is. Typing a value of its own into a field also lets go of the variable.
An agent gives bindings, an object of property to variable, by name or id:
{
"nodes": [
{
"kind": "frame", "name": "Card", "x": 0, "y": 0, "width": 272, "height": "hug",
"fill": "#FFFFFF", "stroke": "#E3E6EC", "corner_radius": 16,
"layout": {"direction": "vertical", "gap": 16, "padding": 16},
"bindings": {"fill": "color/bg/card", "stroke": "color/border", "corner_radius": "radius/card", "padding": "space/md", "gap": "space/md"},
"children": [
{"kind": "text", "text": "Storage", "font_family": "Inter", "font_size": 16, "font_weight": 600, "fill": "#111318",
"bindings": {"fill": "color/text/primary"}},
{"kind": "text", "text": "Manage storage", "font_family": "Inter", "font_size": 13, "font_weight": 600, "fill": "#2F6BFF",
"bindings": {"fill": "color/link"}}
]
}
]
}
The keys include fill, stroke, opacity, width, height, corner_radius, stroke_width, gap, row_gap, padding and each side, min_width, max_width, font_size, line_height, letter_spacing, font_weight, text, font_family and visible, plus the stops of a gradient and the color and numbers of an effect. bindings replaces the bindings a node had; null removes them all and the node keeps its values.
Still give each bound property a real value, as above. It is what the node shows if the variable is ever removed.
The Mode control#
A mode is chosen on the page or on any frame. A frame follows the page unless it is given a mode of its own, and everything inside a frame follows that frame.
With nothing selected, the inspector shows the page: Mode is a segment, Light · Dark. On a frame it is Page · Light · Dark, where Page means "follow the page". With three modes or more it becomes a menu.

An agent sets mode by name with update_nodes:
{"changes": [{"id": "FRAME_ID", "mode": "Dark"}]}
With several sets, name one mode of each: "Theme=Dark, Density=Compact". null makes the frame follow what is around it again.
To check a whole screen in dark, duplicate it and set the copy's mode. Keep the two side by side while you design.
Give a section its own background#
A mode changes what variables hold inside a frame. It does not paint anything. If you switch one section of a light page to Dark and that section has no fill, its text turns light on the page's light background and disappears.

So when one section alone changes mode, give that section a fill bound to a background variable:
{"changes": [{"id": "SECTION_ID", "mode": "Dark", "fill": "#14161B", "bindings": {"fill": "color/bg/page"}}]}
Tokens for code#
Variables are the design's tokens. Every variable has a name for code: color/bg/page is --color-bg-page in CSS, Tokens.Color.bgPage(tokenModes) in Swift (a function of the modes in force) and color.bg.page in JSON. Code built from the design should name these, not copy the hex values.
Export the design tokens as CSS to src/tokens.css.
The agent calls list_variables to read every set, mode and value, and export_tokens to write them:
{"format": "css"}
With a path the text is written to that file. For the Theme set above, the result begins:
:root {
--color-bg-page: #F4F5F8;
--color-bg-card: #FFFFFF;
--color-text-primary: #111318;
...
--color-link: var(--color-accent);
--radius-card: 16px;
--space-md: 16px;
}
[data-theme="dark"] {
--color-bg-page: #14161B;
--color-bg-card: #1E2128;
--color-text-primary: #F2F4F7;
...
}The default mode of each set goes in :root, and each other mode in a [data-<set>="<mode>"] rule holding only what differs. "format": "swift" writes a Tokens namespace for SwiftUI, and "format": "json" writes Design Tokens Community Group JSON with every mode's value.
Next: Styles bundle several values under one name and can follow variables too.