Dark interfaces have gone from developer-tool niche to mainstream. Many brands now design dark first, and almost every operating system offers a system-wide dark setting. A dark theme can look premium and feel comfortable in low light, but it is easy to get wrong. Here is how to decide, design and build one well.
Why choose dark
- Brand character. Dark backgrounds make colour, photography and product shots stand out. Many technology and creative brands use them to feel focused and premium.
- Comfort in low light. In a dim room, a bright white page is harsh. Many people prefer dark interfaces in the evening.
- Battery on OLED screens. On OLED displays, dark pixels use less power, which adds up on phones at high brightness.
When dark is not the best choice
- Long-form reading. Many people read long text more comfortably as dark text on a light background, especially in bright surroundings.
- Some vision conditions. People with astigmatism can see light text "bleed" on dark backgrounds.
- Content that must print or match paper, such as invoices and documents.
If your audience is broad, consider respecting the visitor's system preference, or offering a choice. If your brand is dark by design, make sure long content and forms are still easy to read.
Colour rules for a good dark theme
Avoid pure black. #000000 with white text creates extreme contrast that can feel harsh and makes shadows invisible. Use a very dark grey or navy, such as #0b1220, as the base.
Avoid pure white text. Slightly softened white for body text reduces glare. Keep the brightest white for headings and key numbers.
Show elevation with lighter surfaces. Shadows barely show on dark backgrounds, so raised elements like cards and menus should be a step lighter than the surface beneath them.
Adjust your accent colours. Saturated colours that work on white can vibrate on dark backgrounds. Slightly lighter, less saturated versions usually read better.
Keep contrast in range. WCAG asks for at least 4.5:1 contrast for body text and 3:1 for large text and interface elements such as input borders and icons. Check secondary grey text in particular; it is where dark themes most often fail.
Building it
Use design tokens. Define colours as CSS custom properties with roles, not values:
:root {
--bg-primary: #050914;
--bg-raised: #0c1528;
--text-primary: #f5f7fb;
--text-secondary: #a3adc2;
--accent: #f9556d;
}
Components use var(--bg-raised) rather than a hard-coded hex value, so a second theme only redefines the tokens.
Tell the browser. Setting color-scheme: dark makes form controls, scrollbars and the default background match, so inputs do not appear as bright white boxes.
Respect the system setting. The prefers-color-scheme media query reports the visitor's preference. In Tailwind CSS, the dark: variant can follow it automatically or follow a class you control.
Prevent the flash. If the theme is chosen by JavaScript after load, visitors see a white flash first. Set the background colour in the HTML itself, or run a tiny inline script in the document head that applies the theme before the page paints.
Handle images and logos. Logos with dark text disappear on dark backgrounds. Prepare light versions, add subtle borders around screenshots, and check that charts use colours that work on both.
Testing checklist
- Body and secondary text pass contrast checks.
- Focus outlines are clearly visible on every interactive element.
- Form fields, dropdowns and date pickers are themed, not browser-default white.
- Images, logos and embedded content look right.
- There is no white flash on first load or on navigation.
- Long articles are comfortable to read on a phone outdoors.
A dark theme done well feels calm and confident. Done carelessly, it is just hard to read. The difference is in these details.