Choosing Colors That Work in Both Light and Dark Mode
Design one color system that adapts cleanly to light and dark themes using semantic tokens, tuned accents, and careful contrast.
Read GuideDeveloper
Preview an accent color in light and dark themes side by side and copy the theme CSS.
Developer
Before you commit to an accent color, this light and dark theme previewer shows it in two complete mock interfaces placed side by side. Each mock includes a navigation bar, a card, body text and a button, and the dark version automatically uses a lightened accent so it stays vivid against a dark surface. The tool then writes CSS custom properties for both themes, switched with the prefers-color-scheme media query, giving developers a ready starting point for dark mode support.
Add the declaration color-scheme: light dark to your root element alongside the generated variables, so browsers also switch built-in elements like form controls and scrollbars to match the active theme. Keep variable names based on purpose, such as surface, text and accent, rather than on color names, so the same name can hold a different value in each theme. If you later add a manual toggle, apply the dark values with a data attribute on the html element as well as inside the media query.
FAQ
Define your colors as CSS custom properties on :root, then redefine the same properties inside a @media (prefers-color-scheme: dark) block. Components that use the variables switch automatically when the visitor has dark mode turned on. This requires no JavaScript unless you also want a manual toggle.
prefers-color-scheme is a CSS media feature that reports whether the visitor has chosen a light or dark appearance in their operating system or browser. It returns light or dark, and you can write different styles for each. All current major browsers support it.
A saturated mid-tone color that looks strong on white often appears dim or vibrates uncomfortably against a dark background. Raising its lightness, and sometimes lowering its saturation slightly, restores contrast and keeps it comfortable to read. That is why this previewer lightens the accent for the dark theme.
Most design systems use a very dark gray instead of pure black; Material Design, for example, recommends #121212. Dark gray reduces the harsh glow of bright text on black and leaves room to show elevation with slightly lighter surfaces. Pure black can still suit OLED-focused apps where saving power matters.
Learn more
Design one color system that adapts cleanly to light and dark themes using semantic tokens, tuned accents, and careful contrast.
Read GuideLearn how to choose dark backgrounds, softened highlights, and readable accents without making your UI look muddy or flat.
Read Guide12 of the best website color combinations with HEX codes you can copy, when to use each one, and how to adapt them to your brand while keeping text readable.
Read Guide