10 of 16
Reference colors by role, not by value
Have components ask for a role such as text, surface or warning, and resolve each role per theme. A literal value picked on the light theme stays put when the surface turns dark, and two features that share a hex by coincidence change together when one is restyled.
Dovar(--text) → #f5f5f5 on #262626 (13.9:1)
Don’t#0f172a on #262626 (1.2:1)
Before you ship
- Switch the theme. Does any text or icon keep its light-theme color?
- Which role does this component request, and can the warning change without the action changing with it?
- Do the resolved pairs clear 4.5:1 for text in every theme?