Skip to content

Success token is below WCAG AA as text on light surfaces; *-foreground tokens are white in both themes #2668

Closed

Description

@malibio

Overview

While tokenizing status colors in #2592, contrast-checking every mapping in both themes surfaced a gap in the token set itself rather than a mapping error: there is no green dark enough to use as body text on a light surface.

Problem Statement

app.css light mode defines:

  • --success: 97 45% 46% → 2.83:1 against --card (0 0% 100%)
  • --success-light: 96 64% 69% → 1.52:1 against --card

WCAG AA requires 4.5:1 for normal-size text. Neither variant reaches it, so any success/confirmation text on a white card is below AA in light mode. Dark mode is fine (--success is 6.93:1).

This is not symmetric with the other state colors:

Token on --card, light on --card, dark
--destructive 4.57 ✅ 6.17 ✅
--warning (on tint) passes ✅ passes ✅
--success 2.83 ❌ 6.93 ✅

A second, related gap: --success-foreground and --destructive-foreground are both 0 0% 100% (white) in both light and dark. Pairing them with the solid mid-tone fills — the pairing the names imply is correct — yields 2.55–2.83:1. #2592 had to work around this by tinting backgrounds and using the state color as text.

Known live instance

packages/desktop-app/src/lib/components/collaboration/invitations-inbox.svelte — .ok (rendered with role="status") is hsl(var(--success)) on hsl(var(--card)) = 2.83:1 in light mode. Left as-is in #2592 because every available token alternative scored worse; documented in that commit as a known residual.

Proposed Solution

Options, roughly in order of preference:

  1. Add a darker success variant for text use (e.g. --success-strong, ~30-35% lightness in light mode) and point text-context usages at it. Mirrors how --destructive already happens to work.
  2. Darken --success itself in light mode to ≥4.5:1 on white. Cheapest, but changes existing fills wherever --success is a background.
  3. Fix the *-foreground tokens so they carry a genuine light/dark pair instead of being white in both, making solid-fill pairings viable and removing the need for the tint workaround.

Option 3 is worth doing regardless of 1/2, since it affects --destructive/--warning badges too.

Acceptance Criteria

  • Success text on a light surface meets 4.5:1 (normal text) in both themes
  • --*-foreground tokens produce ≥4.5:1 against their paired solid fill in both themes, or are documented as fill-only with a sanctioned alternative
  • .ok in invitations-inbox.svelte updated to the new token and verified
  • Existing --success / --success-light consumers audited for regression (grep -rn "var(--success" packages/desktop-app/src)
  • Contrast values recorded in the PR for both themes

Technical Specifications

  • Token source: packages/desktop-app/src/app.css — light on :root, dark on .dark (class-based, not a media query)
  • Tokens are HSL triplets, consumed as hsl(var(--token)) / hsl(var(--token) / alpha)
  • Verify with a relative-luminance contrast calculation per WCAG 2.1, not by eye

Related Issues

Activity

  1. malibio commented on Sep 16, 2026

    @malibio
    CollaboratorAuthor

    Constraint: fix this with color values only

    Do not add a border, outline, background fill, chip, or any other enclosure to satisfy the contrast requirement. The only lever is the color token itself — Options 1 and 2 in the description (add --success-strong, or darken --success) are the sanctioned approaches. Option 3 (*-foreground pairs) is fine as written since it changes token values, not surfaces.

    This has been added to DESIGN.md as a standing Don't rule:

    Don't add a border, outline, or background fill for contrast or accessibility reasons — adjust the color token instead. Contrast comes from the color itself; the surface stays flat. This holds whether or not the change was asked for: an accessibility improvement is not a licence to add enclosure. (Components whose spec already calls for a stroke or fill — Badge, Input, Dropdown — are unaffected.)

    Flagging it here because the rule was previously unwritten and enclosure kept getting reintroduced — including by agents adding it unprompted on accessibility grounds. The spec also reads as if tinted backgrounds are house style (the -light variants are sanctioned "for badge backgrounds", and the Card spec says tonal contrast alone is sufficient), so the pull toward a tinted box here is real.

    Note that #2592's tinted status-pill backgrounds are explicitly out of scope for this issue — they're being reviewed separately. Don't remove them as part of this work.

  2. malibio commented on Sep 16, 2026

    @malibio
    CollaboratorAuthor

    Baseline on worktree issue-2668-state-token-contrast (branched from main @ 458a332): Frontend 246 test files / 5078 tests passed, exit 0.

    Scope expansion: an audit of all four state tokens in every usage context found this is a LIGHT-MODE-ONLY problem (dark mode passes AA everywhere: success 7.04, destructive 6.27, warning 8.98, primary 5.44 on --background), but that THREE tokens fail in light mode, not just --success:

    --warning 2.15 as text on white / 1.99 on a 0.1 tint (worse than --success)
    --success 2.83 / 2.58
    --primary 3.67 / 3.28 (AA-large only; fails for body text)
    --destructive 4.57 / 3.92 (the only one genuinely OK)

    --warning was missed when this issue was filed because it was written from the single --success instance encountered in #2592. Amber-on-white is the more severe offender.

    Also measured: text on a 0.1 tint of its own hue is HARDER than on plain white, since the tint darkens the background in the same hue. status-bar.svelte uses exactly that pattern, so it sets the binding constraint.

  3. self-assigned this
    on Sep 16, 2026
  4. added a commit that references this issue on Sep 17, 2026
    e1777c2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions