The clean way to support light and dark mode in Figma is two layers of variables. A primitive collection holds raw colour scales. A semantic collection holds roles such as background and foreground, with a Light mode and a Dark mode that point to different primitives. Components use only semantic variables, so switching a frame’s mode switches the whole design at once.
This guide shows the full setup step by step, with the token list we use in Nivo UI and the fixes that make dark mode actually readable.
Why two layers matter
If a button uses violet/600 directly, dark mode means editing every button by hand. If the button uses primary, and primary points to violet/600 in Light and violet/500 in Dark, the switch is automatic.
One layer holds values. The other holds meaning. Components only ever talk to the meaning layer.
Step 1: Build the primitive scales
Create a collection called Primitives. Add a full scale for each colour you use, from 50 to 950:
- A neutral gray scale for text, surfaces and borders
- Your brand colour scale
- Red, amber and green scales for errors, warnings and success
Primitives have one mode only. Hide them from publishing so designers do not pick a raw value by mistake. In Nivo UI this collection holds 248 primitives.
Step 2: Create the semantic collection
Create a second collection called Color with two modes: Light and Dark. Then add tokens by role. A practical starting set:
| Token | Light points to | Dark points to | Used for |
|---|---|---|---|
background |
white | gray/950 | Page and app background |
foreground |
gray/950 | gray/50 | Main text |
muted |
gray/100 | gray/900 | Subtle surfaces |
muted-foreground |
gray/500 | gray/400 | Secondary text |
primary |
violet/600 | violet/500 | Main buttons, links |
primary-foreground |
white | white | Text on primary |
border |
gray/200 | gray/800 | Dividers, card edges |
control-border |
gray/300 | gray/700 | Input and outline button borders |
ring |
violet/600 | violet/400 | Focus rings |
destructive |
red/600 | red/500 | Errors, delete actions |
The values here are a starting point. Test them with your own brand and adjust.
Step 3: Alias, do not copy
Every semantic token should be an alias to a primitive, never a raw hex value. In the value field, pick the primitive instead of typing a colour. When the brand colour changes later, you update one scale and every token in every mode follows.
A hex value hiding inside a semantic token is the most common reason a theme change misses some screens.
Step 4: Set scoping
Scoping controls where a variable appears in the picker:
backgroundandmutedtokens: fills only- foreground tokens: text only
- border tokens: strokes only
Designers then see only the options that make sense for what they selected. That prevents text colours ending up as backgrounds, and keeps the picker short.
Step 5: Apply tokens to components
Rebuild or rebind each component to semantic tokens only:
- Buttons use
primaryandprimary-foreground - Inputs use
background,control-borderandforeground - Focus rings use
ring - Errors use
destructive
Check each component in both modes before moving to the next. Fixing one component now is far cheaper than finding problems across fifty screens later.
Step 6: Switch modes on frames
Select a frame and change its variable mode from Light to Dark in the layer’s appearance settings. Every child that uses semantic tokens switches with it.
On each component page, show Light and Dark frames side by side. Reviewers can then check both modes at a glance, and nobody forgets dark mode when a component changes.
Step 7: Check contrast in both modes
Dark mode is not inverted light mode. Common fixes:
- Lift the primary colour one step lighter in dark mode so it stays readable on dark backgrounds
- Use slightly lighter borders than you expect; dark borders disappear on dark surfaces
- Avoid pure black for long reading; a very dark gray is easier on the eyes
- Reduce shadow opacity in dark mode, or shadows look heavy and muddy
- Check text at 4.5:1, and borders, icons and focus rings at 3:1, against their backgrounds
Step 8: Hand off to code
Semantic names map straight to CSS variables or Tailwind theme values. If your team uses shadcn/ui, matching its token names, such as background, foreground, primary, muted, border and ring, means developers can copy values across with almost no translation. AI coding tools also read these names correctly, which makes design-to-code faster.
Common mistakes
- Semantic tokens holding raw hex values instead of aliases
- Components mixing primitive and semantic variables
- No scoping, so the picker shows hundreds of options
- Shadows that look heavy in dark mode
- Hover and disabled states never tested in dark mode
- Brand colour used for text on dark backgrounds without a contrast check
Use a setup that is already done
Nivo UI ships with 248 primitives, 50 semantic colour tokens in Light and Dark modes, and layout and typography variables, all named shadcn-style. Every component is bound, so dark mode is one switch. It launches free on Figma Community on December 15. Get it at nivoui.com.
FAQ
Do I need two collections for dark mode? It is strongly recommended. One collection for primitives and one for semantic roles keeps theme changes safe.
Can I add more themes later? Yes. Add a mode to the semantic collection, for example a brand or high-contrast theme, and point its tokens to different primitives. Check how many modes your Figma plan allows.
Should text styles change between modes? No. Text styles hold size and weight; colour comes from semantic variables.
What is the difference between primitive and semantic tokens? Primitives are raw values like violet/600. Semantic tokens are roles like primary that point to a primitive, and can point to a different one in each mode.