Dark mode done badly is a light design with the colours flipped: grey text that’s hard to read, orange that glows, shadows you can’t see and a white flash every time a page loads. Done properly, it’s a second theme designed on purpose, built from the same parts as the first, and checked just as carefully. Here’s how we do it, on this site and for clients.

Start with names, not colours

The trick that makes two themes manageable is never to use a colour directly in a component. Instead, every colour has a name that says what it’s for: “page background”, “main text”, “primary button”. Those names are semantic design tokens. Light mode points each name at one colour; dark mode points the same name at another.

So a button never says “orange”. It says “primary action”, and each theme decides what that means. Add a theme and every component follows, with no component changes at all. You can see this on Somnia DS, our design system: every example is shown in light and dark side by side, from one set of components.

Design dark mode, don’t invert it

  • Don’t use pure black. A very dark navy or grey is easier on the eyes and leaves room for surfaces to sit “above” the page. We use a deep ink rather than #000.
  • Lift surfaces with lightness, not shadow. Shadows barely show on a dark page. Cards and menus read as raised when they’re slightly lighter than the page behind them.
  • Turn down the brightness of colour. Saturated colours vibrate on dark backgrounds. Our accent is a deep rust in light mode and a softer, lighter orange in dark mode: the same brand, tuned for each background.
  • Soften the text. Pure white text on near-black is harsh for long reading. Off-white works better.
  • Check images and logos. A logo with dark lettering disappears on a dark page. Give it a light variant, or a tile behind it.

Check contrast in both themes

Every pairing of text and background has to meet WCAG contrast in both themes: 4.5:1 for normal text, 3:1 for large text and for the edges of controls like inputs and buttons. A colour that passes on cream can fail on navy, and the other way round. We check every page in both modes with automated tools on every change, and look at anything new by eye.

Respect the device, then the person

  • Follow the system setting by default. CSS can read whether someone’s device is set to dark (prefers-color-scheme), so a new visitor gets what they already chose.
  • Let people override it. Some people want dark at night and light by day, whatever their phone says. Offer light, dark and automatic, and remember the choice in the browser.
  • Tell the browser. The color-scheme property makes form controls, scrollbars and the page behind your content match the theme.

Don’t flash on load

The classic bug: the page loads light, then a moment later switches to dark. It happens when the saved choice is applied by a script that runs after the page has drawn. The fix is a tiny script in the page’s <head> that reads the saved choice and sets the theme before anything is drawn. It’s a few lines, it costs nothing, and it removes the flash completely.

Remember paper

Nobody wants a printed page with a black background. Whatever theme is on screen, print on light paper. We go further and print in the brand’s colours with the fonts intact; it’s all in the ultimate print experience for websites.

A checklist

  • Every colour in components comes from a semantic token
  • Dark mode designed, not inverted: no pure black, lighter raised surfaces, toned-down colour
  • Contrast checked in both themes, including control edges and focus rings
  • Logos and images checked on both backgrounds
  • Follows the device setting; a visible switch overrides it and is remembered
  • No flash of the wrong theme on load
  • Prints on light paper

Adding dark mode to a product, or tidying one that’s grown messy? Get in touch. It’s usually easier than it looks once the tokens are right.

← Back to all insights