How to use CSS Theme Token Builder
- Edit the Light and dark CSS variables rows or the JSON array. Give each token a unique name without -- and valid light and dark values.
- Choose whether a device’s dark preference should apply when the root has neither data-theme="light" nor data-theme="dark". An explicit light or dark choice takes priority.
- Select Build theme tokens and inspect the CSS, then copy or download the CSS and JSON.
- Use the custom properties in actual declarations, such as background: var(--surface). Implement any theme switch separately and check contrast in both themes.
Example: CSS Theme Token Builder
Define a white light surface and a dark surface, with system preference as a fallback.
Options
- Names and value types
- Use 1 to 50 unique lowercase names beginning with a letter, followed by letters, digits or hyphens, up to 48 characters. Omit --. Both values for a token must be colors or both lengths, though their length units can differ.
- Theme selection
- The exported root defaults to light values. data-theme="light" and data-theme="dark" on the root select an explicit mode. With the system option on, dark device preference applies only when neither explicit value is present.
- Using the values
- An exported variable must be referenced by a CSS property to affect a page. var(--token, fallback) handles a missing variable in a browser with custom-property support; it does not add a working theme toggle.
Supported inputs and limits
- Only documented value types are accepted.
- No arbitrary declarations, URLs, expressions or injected selectors.
- Generated tokens do not check contrast, implement a theme switcher or provide a browser compatibility guarantee.
- One to 50 tokens in at most 20,000 JSON characters.
- Names are lowercase and at most 48 characters.
More details
Light and dark values must share a type: opaque HEX colors or nonnegative lengths up to 10,000 px or 100 rem/em/%, with at most four decimal places.
Native rows supplement the advanced JSON input.
Theme tokens are generated values; they do not automatically establish readable contrast on a complete site.
Where your input is processed
This tool does not upload your inputs. See the limits for anything saved on your device.
A token needs a consumer
Use the exported custom properties in actual declarations such as background: var(--surface). Merely defining a variable does not style an element. Check all text and control boundaries in both themes, since two valid color values can still have poor contrast. Unsupported declarations and URLs are refused rather than copied into the generated stylesheet.
Questions about CSS Theme Token Builder
Does this add a theme switch to my site?
No. It exports declarations and selectors. Your site must implement the switch and retain its state if needed.
Can I paste a whole CSS declaration as a value?
No. Enter a supported value only. Braces, declaration separators and other injection forms are refused.
Do the dark values pass contrast?
They are your chosen values. Check each foreground/background pair separately.
What does the CSS fallback support?
var(--token, fallback) supplies a value when the property is missing in a browser that supports CSS custom properties. For older browsers, add a separate literal declaration before the var() declaration.