BlogUI/UX

Colour Contrast in Dark Mode: A Practical Step-by-Step Fix

Dark mode isn't just inverted light mode. Here is a step-by-step way to build dark palettes that stay readable, using WCAG contrast ratios as your check.

Denny Pratama

25 Nov 2026 · 6 min read · UI/UX

Colour Contrast in Dark Mode: A Practical Step-by-Step Fix

Most dark modes I've seen start the same way: someone takes the light palette, flips the lightness, and calls it done. It looks fine in a screenshot. Then the grey helper text turns muddy, the borders vanish, and the brand colour buzzes against the background.

I'm a designer, not an accessibility specialist, so I lean on documented rules and a repeatable process. Here is the process I'd follow for a dark palette, in order.

01Why inversion fails

A light palette is tuned for dark text on a light surface. Flip it and several things break at once:

  • Mid-greys that passed on white may fall below the threshold on dark grey.
  • Saturated brand colours look more intense on dark backgrounds, which can feel like glare.
  • Shadows, which signal depth in light mode, barely show on dark surfaces.

So treat dark mode as its own palette that shares the same roles, not as a filter over the light one.

02Step 1: Define roles, not colours

Before picking any hex values, list the roles your UI uses. A small product might need:

  • Background (page)
  • Surface (cards, panels)
  • Surface raised (menus, modals)
  • Text primary
  • Text secondary
  • Border
  • Accent
  • Danger, success, warning

Name them by role (text-secondary) rather than by value (grey-500). Each theme then assigns its own value to the same role. This also makes handoff far easier, because a developer, or an AI coding tool, maps roles to CSS custom properties instead of guessing which grey you meant.

03Step 2: Know the thresholds you're checking against

These come from WCAG 2.x and are widely documented:

  • Normal text: 4.5:1 against its background.
  • Large text (roughly 18pt, or 14pt bold, and up): 3:1.
  • UI components and meaningful graphics (input borders, icons, focus indicators): 3:1 against adjacent colours.

These apply in dark mode exactly as in light mode. Placeholder text, disabled-looking-but-still-needed labels and helper text are where most failures hide. Truly disabled controls are exempt, but "secondary" text is not.

04Step 3: Build the surface ladder

Pick a base background, then step up in lightness for each elevation level. Say your page background is a very dark grey. Cards sit one step lighter, and menus and modals one step lighter again.

This replaces shadows as your depth cue. Keep the steps small but visible, and keep them few. Three or four levels are usually enough.

Then check your text against every level, not just the page background. Text that passes on the page can fail on the lightest raised surface, because that surface is closer in lightness to the text.

05Step 4: Set text colours and test each pairing

Start with primary text. Many designers avoid pure white and choose a slightly softer off-white to reduce harshness. Either can be fine, as long as it passes comfortably.

Then secondary text. This is the usual offender. Pick a value, test it against background, surface and raised surface, and keep adjusting until the lowest pairing still clears 4.5:1.

A simple working method:

  1. Make a list of every text role and every surface it appears on.
  2. Test each pair with a contrast checker, using exact hex values.
  3. Record the ratio next to the pair in your design file.
  4. Fix the failures by lightening the text, not by darkening the surface, so you don't break the ladder.

It's tedious for about an hour, and then you never have to do it again for that palette.

06Step 5: Re-tune the accent and status colours

This is where inversion hurts most. A brand blue that works as a button background in light mode may be too dark to read as link text on a dark surface. Often you need a lighter, slightly less saturated version for dark mode.

Check two separate uses:

  • Accent as text or icon (links, active tab): needs contrast against the surface.
  • Accent as a fill (primary button): needs contrast between the button and the page, and between the label and the button.

Those are different pairings, and one can pass while the other fails. Do the same for red, green and amber status colours. And never rely on colour alone to show status. Pair it with an icon or a word.

07Step 6: Don't forget borders, focus and states

Thin borders on dark surfaces tend to disappear. If a border is the only thing marking an input field, it counts as a UI component and needs 3:1 against its surroundings. If that looks too heavy, use a visible fill difference on the input instead, but check that too.

Focus rings deserve their own test. A focus indicator that was clear in light mode can vanish against a dark card. Test hover, pressed, selected and focus states on each surface level. I'd also test them with the keyboard, not just on a static frame.

08Step 7: Review it like a user would

Numbers aren't the whole story. Once the palette passes, do a visual pass:

  • Look at a dense screen, like a table or settings page, and check whether anything looks lost.
  • Look at it at low screen brightness and in a dim room if you can.
  • Check large areas of bright colour, since big bright fills can feel glaring.
  • Check images, logos and illustrations, which often assume a light background.

If you're letting an AI tool build the screens, make this review part of your sign-off. My checklist for reviewing AI-built UI covers the wider pass, and contrast in both themes belongs on it.

09A short checklist to keep

  • Palette defined by roles, not raw colours
  • Three or four surface levels, each tested with all text roles
  • Normal text at 4.5:1 or better, large text at 3:1
  • Borders, icons and focus rings at 3:1
  • Accent re-tuned for dark, tested as both text and fill
  • Status colours paired with icons or labels
  • Hover, pressed, selected and focus states checked on every surface
  • Contrast ratios noted in the design file for handoff

Dark mode done well is mostly bookkeeping. The creative part is small. The value comes from testing every pairing once, writing it down, and handing developers a palette they can implement without guessing.

10Frequently asked questions

What contrast ratio does dark mode need to meet?

The same WCAG 2.x thresholds apply as in light mode. Body text needs at least 4.5:1, large text needs 3:1, and UI components such as input borders and icons need 3:1 against adjacent colours.

Should dark mode use pure black backgrounds?

It's not required, and many product UIs use dark greys instead. Pure black with pure white text can feel harsh, and a dark grey gives you room to show elevation with slightly lighter surfaces. Pure black is still a valid choice, so check it with your own screens.

How do I check contrast without guessing?

Use a contrast checker with the exact hex values of your text and background, or the contrast tools built into your design app or browser dev tools. Check every text and surface pairing, not just the main one.

UI/UX

Denny Pratama

Product designer in Indonesia. Since 2018 I’ve designed SaaS products, dashboards and marketing sites, and now I build my own designs too.

About me