Dark Mode
Serving an alternate palette for low-light preference, and the three states that implies.
Dark mode is an alternate color 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 color 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
Design Token
Named design decisions — color, spacing, radius, type — stored as data so they can be shared and re-themed.
Design & Interface17 connections
CSS Custom Property
A user-defined CSS property that participates in the cascade and inherits down the tree.
Design & Interface10 connections
Scoped Styling
Confining a set of style decisions to a subtree so the same component can look different in different contexts.
Design & Interface10 connections
OKLCH
A perceptually uniform color space that makes lightness and chroma behave predictably.
Design & Interface13 connections
Related4
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from10
- 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 — color, spacing, radius, type — stored as data so they can be shared and re-themed.
- OKLCHDesign & Interface
A perceptually uniform color space that makes lightness and chroma behave predictably.
- Opponent Process TheoryDesign & Interface
Color is recoded after the cones into red-green, blue-yellow and light-dark opponent channels.
- Polarized LightMatter & Energy
Light whose electric field oscillates in a preferred orientation, and the filters that select for it.
- Scoped StylingDesign & Interface
Confining a set of style decisions to a subtree so the same component can look different in different contexts.
- SkeuomorphismDesign & Interface
Designing a digital object to visually mimic its physical predecessor, borrowing familiarity at the cost of extra visual weight.
- Utility-First CSSDesign & Interface
Composing styles from many small single-purpose classes rather than authoring semantic rules.