Dark Mode
Serving an alternate palette for low-light preference, and the three states that implies.
Dark mode is an alternate colour scheme for interfaces, driven either by the operating system's stated preference or by an explicit choice within the application.
The important structural fact is that there are three states, not two: light, dark, and unset. An explicit choice usually stamps a marker on the document root; the default "follow the system" setting stamps nothing, leaving only the media query to distinguish light from dark. A theme implementation that handles only two states will get the third wrong, usually by ignoring an explicit choice or by ignoring the system preference.
The robust shape is: define the complete light palette on the bare root selector, redefine only the changed tokens under the dark media query guarded against an explicit light choice, and redefine them again under an explicit dark marker so the toggle wins in both directions. No colour should have its only definition inside a media query.
Two practical notes. Because the common implementation toggles a class on the root element, code that needs to observe the current theme must watch that element rather than the media query — the media query reports the system preference, not the applied theme. And dark mode is not an inversion: shadows, image treatment, and contrast ratios all need separate consideration; see Color Contrast.
See also4
Hand-picked in the note itself — the neighbours worth reading next.
Design Token
Named design decisions — colour, spacing, radius, type — stored as data so they can be shared and re-themed.
Design & Interface14 connections
CSS Custom Property
A user-defined CSS property that participates in the cascade and inherits down the tree.
Design & Interface9 connections
Scoped Styling
Confining a set of style decisions to a subtree so the same component can look different in different contexts.
Design & Interface9 connections
OKLCH
A perceptually uniform colour space that makes lightness and chroma behave predictably.
Design & Interface10 connections
Related4
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from7
Notes elsewhere in the wiki that reach for this one.
- CascadeDesign & Interface
The algorithm deciding which declaration wins when several apply to the same element.
- Color ContrastDesign & Interface
The measured luminance difference between foreground and background, and the accessibility floor it must clear.
- CSS Custom PropertyDesign & Interface
A user-defined CSS property that participates in the cascade and inherits down the tree.
- Design TokenDesign & Interface
Named design decisions — colour, spacing, radius, type — stored as data so they can be shared and re-themed.
- OKLCHDesign & Interface
A perceptually uniform colour space that makes lightness and chroma behave predictably.
- Scoped StylingDesign & Interface
Confining a set of style decisions to a subtree so the same component can look different in different contexts.
- Utility-First CSSDesign & Interface
Composing styles from many small single-purpose classes rather than authoring semantic rules.