---
title: "Illuminating dark mode"
description: "Figma built dark mode by replacing roughly 5,100 build-time PostCSS color variables with runtime CSS custom properties based on a semantic token schema (Type | UI Element | Color role | Prominence | Interaction), so new themes only require reassigning token values."
url: "https://swe.quest/articles/illuminating-dark-mode-f998d746316f5fd8"
canonical: "https://www.figma.com/blog/illuminating-dark-mode/"
source: "Figma"
published: "2022-07-21"
difficulty: "medium"
kind: "Case study"
reading_minutes: 15
tags: ["design-systems","css","frontend","refactoring","accessibility"]
---

# Illuminating dark mode

A post on [Figma](https://swe.quest/sources/figma.md), published 2022-07-21, 15 min read, Case study. Original: [https://www.figma.com/blog/illuminating-dark-mode/](https://www.figma.com/blog/illuminating-dark-mode/)

## Summary

Figma built dark mode by replacing roughly 5,100 build-time PostCSS color variables with runtime CSS custom properties based on a semantic token schema (Type | UI Element | Color role | Prominence | Interaction), so new themes only require reassigning token values. Tokens are exported in the Design Tokens Format Module spec and compiled to CSS, Swift and XML. To spread the mostly manual refactor, forty engineers covered about 80% of in-scope surfaces in a single 'Dark Mode Week'. Supporting tooling included CSS fallbacks to the legacy variables to prevent regressions, a debug theme with random saturated colors to reveal unconverted surfaces, and a CIELAB-based search tool for finding the closest matching token.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Design systems](https://swe.quest/tags/design-systems.md) (Web & mobile)
- [CSS](https://swe.quest/tags/css.md) (Web & mobile)
- [Frontend](https://swe.quest/tags/frontend.md) (Web & mobile)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)
- [Accessibility](https://swe.quest/tags/accessibility.md) (Web & mobile)

## Prerequisites

- CSS custom properties ([easy posts on CSS](https://swe.quest/tags/css.md?difficulty=easy))
- CSS preprocessors ([easy posts on CSS](https://swe.quest/tags/css.md?difficulty=easy))

## Keywords

Figma, Dark mode, CSS custom properties, PostCSS, Design Tokens Format Module, CIELAB, FigJam

## Related posts

- [Theming the Zalando Design System](https://swe.quest/articles/theming-the-zalando-design-system-b14098d887a4b230.md): Zalando Engineering · 2024-05-13 · Medium · 20 min read · Design systems, Frontend, CSS, Mobile
  Zalando built theming into its design system by extracting repeated values into semantic design tokens (e.g. \`accent\` instead of \`orange\`) and adding component-level tokens that reference global ones, so themes can change a button's padding without redefining global scales.
- [Dark mode was never on our roadmap. Here’s how it got built.](https://swe.quest/articles/dark-mode-was-never-on-our-roadmap-here-s-how-it-got-built-65fcd1920934b974.md): Medium Engineering · 2026-10-22 · Medium · 17 min read · CSS, Frontend, Design systems, CDN & edge, AI for coding
  Medium shipped dark mode for its reader experience with essentially one engineer working between other projects, guided by three guardrails: keep it safe, keep it small, keep it concrete.
- [Design Systems @ Replit: Better Tokens](https://swe.quest/articles/design-systems-replit-better-tokens-145fca0668bb5424.md): Replit · 2021-10-26 · Medium · 5 min read · Design systems, CSS, Frontend
  Replit rebuilt the token layer of its RUI design system, the base of a hierarchy running tokens → utilities → components → patterns → design guidance.
- [The making of the Figma Pattern Library](https://swe.quest/articles/the-making-of-the-figma-pattern-library-500fd6e5ca81c90e.md): Figma · 2024-11-21 · Medium · 9 min read · Design systems, Frontend, Accessibility
  Figma rebuilt its fragmented internal design system as the Figma Pattern Library (FPL) ahead of the UI3 redesign, with a small team of designers and engineers working in a paired style.
- [Unlocking inclusive design: how Primer’s color system is making GitHub.com more inclusive](https://swe.quest/articles/unlocking-inclusive-design-how-primer-s-color-system-is-making-github-com-more-438d95888d234cb3.md): GitHub Engineering · 2023-05-11 · Medium · 6 min read · Accessibility, Design systems, CI/CD, Frontend
  GitHub's Primer design system fixed hundreds of color contrast violations across light and dark modes and all themes by changing its foundational color tokens (Primer Primitives) rather than individual components.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
