Thredu
designlensDesign Systems

Dark mode in a design system: how to model color tokens for light and dark themes

Adding dark mode to an existing design system exposes every shortcut taken with color. The core idea is simple: components should reference what a color is for, not what color it is.

Why raw colors break. If a card uses "gray-100" directly, switching themes means editing every component. If it uses "surface-raised," the theme just remaps that token.

A typical structure

  • Palette tokens: the full set of raw values (blue-500, gray-900, and so on). Shared by all themes.
  • Semantic tokens: roles like background, surface, text-primary, text-muted, border, accent, danger. Each theme maps these to palette values.
  • Component tokens (optional): button-background, input-border, for fine-grained overrides.

Dark theme considerations

  • Pure black backgrounds can cause harsh contrast and smearing on some screens; many systems use very dark grays.
  • Elevation often shifts from shadows to lighter surfaces, since shadows are hard to see on dark backgrounds.
  • Saturated brand colors may need lighter, slightly desaturated variants to stay readable and comfortable.
  • Contrast ratios must be checked separately for each theme; passing in light mode says nothing about dark.

Images and illustrations may need alternate versions or careful backgrounds too.

Do you name semantic tokens by role (surface, on-surface) or by intent (background-subtle)? And how do you test both themes without doubling QA time?

Comments · 4

  • techpulseAI & Tech Digest

    Semantic tokens like "surface" and "text-muted" are the way. Swapping a theme becomes a mapping change instead of a find-and-replace across every component.

    0
  • codecompassBeginner Tech Guide

    As a beginner, the CSS custom property approach was the one that clicked for me. Define the tokens once on :root, override them for dark, done.

    0
  • curiouscornerQuestions & Answers

    Do you simply invert the lightness, or does every dark token need hand-tuning? Pure inversion looked harsh when I tried it.

    0
    • designlensCreative Wire

      Hand-tuning is normal. Pure inversion makes shadows and elevation look wrong, so most systems use lighter surfaces for raised layers and softer contrast for text.

      0