Skip to content

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

Earendil 12 min read Deep dive mediumAdept

There are many themes, but this one is yours

Pi's new default system theme queries the terminal for its foreground, background and 16 ANSI colors, keeps their hue and chroma, and recomputes lightness so that around 60 UI color roles meet per-surface contrast rules. Because ANSI palettes have no contrast guarantees (an analysis of 460+ Ghostty themes shows bright variants and bright black often fail WCAG minimums), Pi solves lightness using fifth-degree polynomials fitted by a coding agent to a reversed perceptual contrast algorithm, taking the strictest rule per color. Colors are built in OKHSL with a saturation falloff toward black and white, plus a chroma cap so a moved color is never more vivid than the original, a fix prompted by Catppuccin Frappé looking oversaturated.

Assumes: RGB color basicsWCAG contrast ratioterminal ANSI colors

Related posts

  • How to have the browser pick a contrasting color in CSS

    WebKit mediumAdept

    CSS `contrast-color()` takes one color and returns black or white, whichever contrasts more, so a single variable like `--button-color` can drive both background and text, including hover states built with relative color syntax. The current spec uses the WCAG 2 contrast algorithm, which often picks the perceptually worse option on mid-tones (black on #317CFF scores 5.45:1 against 3.84:1 for white, though white is clearly more readable). APCA, a WCAG 3 candidate, scores contrast perceptually and accounts for font size and weight. The function only picks the better of two options, not a sufficient one, so it should be paired with careful palette design and `prefers-contrast` overrides. The CSSWG limited it to black/white so the algorithm can be swapped later without breaking sites.

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

  • Customizing Color Fonts on the Web

    WebKit mediumAdept

    WebKit (Safari 15.4+) supports the CSS `@font-palette-values` at-rule, which lets authors select a color font's predefined CPAL palettes by index and override individual palette colors, then apply them with the `font-palette` property. Browsers without support fall back to palette 0, which can be guarded with `@supports`. `font-palette: light`/`dark` pick palettes the font marks for light or dark backgrounds and pair naturally with `prefers-color-scheme`. Because palette rules are scoped per font family, one palette name can map to different palettes across fallback fonts. Foreground-color shapes in some fonts follow the `color` property instead, and authors should keep palette contrast high for legibility.

  • Add wide gamut P3 and alpha transparency to your color picker in HTML

    WebKit mediumAdept

    `<input type="color">` now supports two new optional attributes, `alpha` and `colorspace`, added to the HTML standard with WHATWG and first shipped in Safari 18.4. With `colorspace="display-p3"` users can pick from the full P3 wide gamut, `limited-srgb` keeps the old 8-bit sRGB behavior, and `alpha` adds an opacity control. The `value` attribute now accepts any CSS color syntax, such as named colors, `oklab()` or `color(display-p3 ...)`, not just hex. Older browsers fall back to an sRGB picker without opacity, and to black for unsupported value syntax, so the attributes can be used today as progressive enhancement.

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

The quest for software engineering knowledge.

Look:
Layout: