Dark mode

Also called dark theme, night mode, or theme toggle animation

An alternate color theme with light text on dark backgrounds, chosen in settings or matched to the device’s system setting.

What is Dark mode?

Dark mode swaps an interface’s light backgrounds for dark ones and flips text to light colors, while the layout stays the same. Most apps offer three choices: Light, Dark, and System, which follows the device setting through the prefers-color-scheme media query.

Build it with color variables instead of fixed colors: define tokens such as --background and --text, then give them new values under a .dark class or a data-theme="dark" attribute on the root element. Every component that uses the tokens switches at once. Set color-scheme too, so scrollbars and form controls match.

Good dark mode takes more than inverted colors. Use dark gray rather than pure black, tone down bright accent colors, show depth with lighter surfaces instead of shadows, and check text contrast again in both themes. Apply the saved theme before the page paints, or visitors see a white flash on load. For a circular reveal like the demo’s, the View Transitions API with an animated clip-path does the job.

All terms

Color contrast

How much text stands out from its background, measured as a ratio from 1:1 to 21:1 and checked against the WCAG levels AA and AAA.

Accent color

The one highlight color an interface uses for actions and selected states, and the CSS property that tints native form controls.

View Transitions API

A browser feature that animates between two states of a page by snapshotting the old view, applying your update, and animating to the new one.

Clip-path

A CSS property that cuts an element to a shape, such as a circle, an inset rectangle, or a polygon, and hides everything outside it.