Skip to content

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

Medium Engineering 17 min read Case study mediumAdept

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

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.

Related posts

  • Illuminating dark mode

    Figma mediumAdept

    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.

  • The New York Times Games’ Path to Dark Mode

    NYT Open easyNovice

    Shipping Dark Mode for New York Times Games turned into paying down years of design debt, because eight games each had their own hex colors, fonts and component styles. The team limited scope to the Games app and launched Dark Mode game by game. They consolidated hex values into primitive and semantic design tokens across three libraries (Games Home, Games Brand, Gameplay), and tuned colors such as Connections' beige tiles so play feels the same in both modes. Implementation uses CSS variables in a React/TypeScript design system with a Provider and hooks, enabling per-game, per-surface rollout. Dark Mode users go on to play and complete more puzzles.

  • Introducing Adaptive Dark Mode

    WebKit mediumAdept

    Safari 27.3 beta adds Adaptive Dark Mode, which automatically darkens light websites that don't declare dark mode support via color-scheme. Inside WebKit, a luminosity-inverting color matrix preserves hue, text contrast targets WCAG 4.5:1, SVGs are recolored, simple black-and-white bitmap logos are detected via pixel histograms, and canvas, masks and mix-blend-mode are left alone or disabled. Sites can opt out with `color-scheme: light only`, improve results by using SVG, CSS colors and transparent images, or ship a custom dark mode using color-scheme, prefers-color-scheme and light-dark(). Websites cannot detect the transformation, because JavaScript sees the original authored colors, which avoids adding a fingerprinting signal.

  • 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.

  • How The New York Times Games Team Delivered Accessible, Cross-Platform Dark Mode

    NYT Open mediumAdept

    The New York Times Games app shipped dark mode across Android, iOS and hybrid webviews by moving from hard-coded colors to semantic design tokens (e.g. "Background Primary" became "$bg-page") through a legacy-to-new color mapping. Android handled XML and Jetpack Compose screens separately. On iOS, UIKit screens needed overrideUserInterfaceStyle and traitCollectionDidChange observers, while SwiftUI screens used @Environment(\.colorScheme) with asset catalogs. Shared NYT packages such as login and avatar selection had to be updated in coordination with the app. Illustrations were reworked by hand rather than color-inverted, and a standalone badge-detail webview takes a "dark" query parameter so it follows the app's global setting.

The quest for software engineering knowledge.

Look:
Layout: