Files
pipelines/app/notes/design-high-contrast.md
T
2026-12-04 00:39:57 +00:00

6.8 KiB

High contrast design

An accessibility design (Settings > Design > High contrast, id high-contrast) for low vision and phones in sunlight: a pure black page with white ink and one bright yellow accent (dark), or a pure white page with black ink and a deep blue accent (light); larger, heavier type; 2px borders on every control and panel; flat surfaces with no shadows; 6px corners; 48px targets on every platform; and a 3px keyboard focus ring with an offset.

Files: lib/ui/theme/high_contrast_{palette,theme,controls,typography}.dart, lib/ui/theme/design_focus_ring.dart, lib/features/chat/ui/transcript/boxed/.

Tokens added to AppDesignTokens (defaults keep every other design)

token default High contrast read by
stroke 1 2 frameSide, GlassPill (flat), settings groups, avatars, stack labels, graph edges, floating windows, boxed transcript
ringStroke 2 3 the send button's usage ring
focusRing (FocusRingStyle: color, halo, width, offset) null accent, page halo, 3px, 2px offset DesignFocusRing
largeTargets false true prefersCompactHitTargets (false: touch rows and 48px targets on a desktop)
minContrast null 4.5 chat colours moved to 4.5:1 against the page (colorWithContrast), no chat tints (list rows, header bar, stack labels outline instead), solid usage-ring track, avatars' marks and frames at full strength
windowRadius null (12) 6 floating windows' corners
snapSwitch false true AppDesignController.themeAnimationDuration: a live switch into or out of the design snaps (no grey-on-grey half-blend; its larger component sizes have nothing to blend from, and with the blend the browser bench's live-switch scenario hung under skwasm twice)

Styles added: TranscriptStyle.boxed, SelectedRowStyle.inverted. AppDesignTokens.inverseTheme(theme) gives the same design in the opposite brightness (cached), which an inverted surface draws its content under.

Surfaces

  • Palette: every surface container is the page; panels part by borders. secondaryContainer is the ink, so selected things (navigation indicator, chips, segmented buttons, list tiles) are inverted.
  • Type: body 17/16/14px at weight 500, labels 16/14/13px and titles at 600. Sizes stay theme roles, so text scaling and the system's bold-text setting apply. Button text keeps the theme's labelLarge (a button style's own text style would fail to blend during a live design switch).
  • Controls: filled/outlined/elevated/segmented buttons, chips, fields, search bars, checkboxes and switches have 2px borders; fields take 3px of the accent when focused; text and icon buttons stay unframed. Disabled ink is #8F8F8F on black (6.5:1) and #6E6E6E on white (5.1:1).
  • Floating pieces: menus, dialogs, sheets framed 2px, no elevation; tooltips inverted, 16px weight 600, padded 12x8, framed in the page colour; snack bars inverted with a 2px edge and the inverse accent for actions.
  • Focus: DesignFocusRing (inserted in the three MaterialApp.builders) draws the ring around FocusManager.primaryFocus over the whole app, a page-coloured halo inside a 3px accent ring 2px outside the control; a text field's ring goes round its whole decorated box. Like :focus-visible it shows after a key press and hides on any pointer press. It tracks a scrolling control with post-frame checks only (no frames scheduled).
  • Chat (boxed): the operator's turn under a bold "You" label in a box with a 2px ink frame and a 6px bar in the chat's colour (ink when none), painted in one pass (BoxedFramePainter, canvas clip, no layer); the agent's answer plain on the page; activity as one bordered block, a row per tool with an icon and a status word ("Done", "Failed", "Running") in a status colour at 7:1 in one aligned column; agent follow-ups as cards framed 2px in the secondary ink; the header bar is not tinted.
  • Lists: the open row is inverted (ink fill, page text, opposite-brightness theme so its status colours keep contrast) with a 6px bar; unselected chat rows show their colour only as their bar and avatar frame.
  • Graph: edges as heavy as the frames (2px), the selected node inverted; edge hover and tooltip unchanged (accent glow at 2.5x the edge, inverse tooltip).
  • Phone chat stack: discs and labels flat in 6px corners; a label's chat colour is a 3px outline, the Add disc framed in the full accent.
  • Floating windows: 6px corners and a 2px ink outline.

Still default

  • Icon buttons in toolbars have no frame (strong hover/press overlays and the focus ring instead); text buttons are unframed.
  • Floating window title bars keep their 40px compact icon buttons.
  • Graph node status captions keep their fixed 12px size (preview scale).
  • Markdown, code blocks and links keep the shared rendering (links were already underlined).
  • The system's high-contrast setting does not switch designs by itself; the design is chosen per device like the others.

Contrast (WCAG 2, against the page)

pair dark light
ink 21:1 21:1
secondary ink 13.6:1 12.6:1
accent 14.9:1 9.4:1
text on accent 14.9:1 9.4:1
error 7.6:1 7.4:1
status green / cyan / magenta 15.7 / 13.7 / 9.8 7.4 / 7.4 / 8.5
warning (usage ring) 10.2:1 7.8:1
rules 7.8:1 7.0:1
disabled 6.5:1 5.1:1
chat colours >= 4.5:1 (tested for all 13) >= 4.5:1

test/ui/theme/high_contrast_design_test.dart computes and asserts these.

Perf (tool/perf/design_bench.mjs, skwasm CPU, medians of 3)

scenario Default build/raster ms per frame High contrast
scroll 8.99 / 56.96 3.65 / 14.16
switch chats 10.4 / 52.72 4.45 / 15.41
runs 2.69 / 12.18 2.48 / 7.06
graph 2.04 / 17.41 2.84 / 19.44
live design switches 14.36 / 22.19 5.44 / 13.15 (heap +0.57 MB)

PASS; no off-origin fetch beyond Default's. Flat pieces, no blur, one painter per boxed turn. The chat list's default click points still hit rows 1-3 at 1280x800 (rows at y 124-232, 232-313, 313-393).

Tests

  • test/ui/theme/high_contrast_design_test.dart: tokens, pages, every contrast pair above computed and asserted (7:1 / 4.5:1), all chat colours, flat bordered surfaces, type, inverse theme, the snap, desktop targets, and every other design's new tokens at their defaults.
  • test/ui/theme/high_contrast_widgets_test.dart: focus ring (3px, offset, halo, text-field box, hidden after a pointer press, absent elsewhere), 48px targets on Linux, boxed transcript (You box, Done/Failed, aligned names), inverted row vs Terminal's unchanged row, 200% text scale on a 360px phone with no overflow (light and dark).
  • test/ui/theme/high_contrast_switch_test.dart and High contrast added to compact_switch_test.dart: per-frame switches to and from every design.