Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Figma 15 min read Case study mediumAdept

Illuminating dark mode

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.

Related posts

  • Theming the Zalando Design System

    Zalando Engineering mediumAdept

    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. Colour schemes (default, monochrome-dark, monochrome-light) are first-class within each theme to meet contrast requirements on image-derived banner backgrounds, which raises open questions about native dark mode. Tokens live in TOML files processed by Style Dictionary with custom transforms and formats that emit platform-specific artefacts for web, Android and iOS. Each theme is a partial dictionary deep-merged over the base theme. The tokenization process also simplified the design system and improved cross-platform parity.

  • Dark mode was never on our roadmap. Here’s how it got built.

    Medium Engineering mediumAdept

    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. Work-in-progress CSS sat behind a Statsig feature flag that temporarily split the Cloudflare Workers edge cache. The flash of incorrect theme was avoided by converting hard-coded hex color tokens to CSS variables using light-dark() and color-scheme, which lets the browser pick the theme before first paint without caching a light and a dark copy of every page. Claude audited the codebase for hard-coded and legacy colors and turned the findings into small Linear tickets, while manual QA and designers handled the judgment calls.

  • Design Systems @ Replit: Better Tokens

    Replit mediumAdept

    Replit rebuilt the token layer of its RUI design system, the base of a hierarchy running tokens → utilities → components → patterns → design guidance. Numbered and vague names like `foreground-3` or `font-size-medium` were replaced: colors are named by intended use on a theme-independent "dimmest → strongest" contrast scale, backgrounds by elevation (root → highest), and pixel-based tokens by their measure (`font-size-14`). The set shrank from 83 to 72 tokens even after adding line-height and border-width categories. Raw CSS variables, which let 30–50 typos slip through, were swapped for a typed Emotion `vars` object that gives autocomplete and errors on misspelled tokens.

  • The making of the Figma Pattern Library

    Figma mediumAdept

    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. Color tokens moved out of a Google Sheet into Figma variables: primitive color ramps are aliased by semantic variables that have modes for light/dark themes and for each product. A GitHub Action uses the REST API to open pull requests that sync published variable changes into code tokens. Every component must have Code Connect support before it counts as done, which maps design components to code even when their structures differ. After five months the library had 680+ tokens and 22 component sets with 670+ variants.

  • Unlocking inclusive design: how Primer’s color system is making GitHub.com more inclusive

    GitHub Engineering mediumAdept

    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. The team audited 100+ text/background color pairs against WCAG ratios (4.5:1 and 3:1) and wrote a script that checks every pair across every theme. The script handles semi-transparent colors by first blending the background onto the page background, then blending the text onto that result. The check now runs as a GitHub Action on every Primer pull request, and the changes were rolled out to staff behind a feature flag before going live.

The quest for software engineering knowledge.

Look:
Layout: