Appearance: themes, contrast, text size, density, motion
<0.01 CPU ms
Still
The live demo starts when it’s in view.Pick a theme, size, density or motion: only the preview obeys · arrow keys move within a group
A small appearance system: colour presets as CSS variables (light, dark, two high-contrast, two accent looks), a “Match system” choice that follows the…
What it costs a frame
CPU
<0.01 ms
02468101216.7 ms
GPU
not used
CPU, median
<0.01 ms
CPU, 95th pct
0.32 ms
Draw calls
0
Weight
Light
Measured 7 November 2026 on 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 156, 1920×1080 at 1×. 600 frames × 3 rounds, median kept. What ran: Measured exercising itself: every eighth frame applies the next preset to the preview (twelve custom properties, five attributes), stores it and redraws the form’s state; every third change also steps the text size and density. No cross-fade while measured. Idle, nothing runs. Phones: tiers are being measured next.
apple · Apple A19 Proin a browser tab · 16 November 2026
not timed
<0.01
1.06
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 2026
not timed
<0.01
0.47
Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.
What it needs
Renders with
DOM and CSSPlain DOM and CSS: every current browser.
Your browser
Runs hereNo WebGPU needed
Depends on
NothingNo other packages
What it’s for
An app’s appearance settings
Dark and light themes without a flash
High-contrast and larger-text options
A compact mode for dense tools
Checking a palette against WCAG
A theme change that feels like time passing
Keeping a canvas or shader in step with the page’s colours
Pitfalls, in brief
Import appearance.base.css, then appearance.css (or your own look instead).
Pass the same looks to the controller, the form and the boot script.
Without the boot script in <head>, a dark theme paints white first: the controller runs only once your bundle has loaded.
The text scale sets the target’s font-size as a percentage: on <html> it scales every rem; inside a smaller element only em units follow it.
Stored values are untrusted. readAppearance keeps only known values; never put a stored string into CSS or HTML without it.
9 more in brief
The storage event reaches other tabs only, never the one that wrote.
document.startViewTransition snapshots the whole page and blocks clicks for the fade (about a quarter of a second): keep it to theme changes, and skip it under reduced motion, as the controller does.
Under Windows high contrast (forced-colors) the system’s colours replace the tokens anyway; keep borders and focus outlines real borders and outlines so they still show.
Every new token pair a page uses (warning text on the accent, say) needs adding to the audit, or a failing colour can slip in unnoticed.
propertyFade registers the tokens for the whole page, for good (CSS.registerProperty cannot be undone): a registered token always has a value, so var(--ui-bg, red) never falls back to red anywhere on the page.
propertyFade and paletteBlend move colours and moods only: a look change (lines, corners, shadows) still snaps.
A gliding colour restyles everything under the target on every frame of the fade.
paletteBlend writes the tokens itself each frame and stands aside when anything else paints the target (a device change, say): don’t also put a CSS transition on the same properties, or the two fight.
Mood weights are numbers (0 to 1): use them in calc() and color-mix() with a fallback, var(--ui-mood-night, 0), so a page without moods still works.
14 pitfalls in full, the hook-up guide, the module source and its tests come with the part.
Where it comes from
From HaTac. Fully custom code.
WCAG 2.2 (W3C): the relative luminance and contrast ratio formulas, and the 4.5:1, 7:1 and 3:1 levels the audit holds the presets to
WAI-ARIA Authoring Practices Guide (W3C): the radio group pattern: the form uses native radios in fieldsets, which give it
Björn Ottosson, “A perceptual color space for image processing” (2020): the OKLab colour space and its published matrices, which the palette blend mixes in (written here from the formulas)