Accessible color palette generator

An accessible color palette is a set of UI colors where every text and background pair meets WCAG contrast: at least 4.5:1 for normal text and 3:1 for large text (AA), or 7:1 and 4.5:1 for AAA. Enter one brand HEX to generate a palette that is checked pair by pair.

Enter a brand HEX and get a compact UI palette with background, surface, text, primary and accent roles. Every text and background pair is tested against WCAG AA, and any failing pair is marked clearly.

Generate an accessible palette from one brand colour. The generator builds the five roles, calculates the real contrast ratio for each text and background pair, and labels every result as an AA pass or fail. Copy the CSS variables when the palette is ready, or open the palette contrast fixer to repair a pair that fails.

Using Tailwind v4? Copy the @theme block to register the same palette as --color-* tokens, so utilities like bg-background and text-primary work in your project. For a full palette built for Tailwind, try the Tailwind color generator.

Palette check

All five tested pairs meet WCAG AA at their stated threshold.

Click a swatch to copy its HEX. The text colour on each swatch is chosen for the best contrast.

WCAG AA pair results

Each ratio is calculated from the generated colours above. Normal text needs 4.5:1; UI components and large text need 3:1.

  • Body text on backgroundNormal text#161b27 / #f9fafb16.47:1AA pass (4.5:1)
  • Body text on surfaceNormal text on cards and panels#161b27 / #eff1f515.22:1AA pass (4.5:1)
  • Button label on primaryNormal text on the main action colour#ffffff / #2563eb5.17:1AA pass (4.5:1)
  • Accent text on backgroundLinks and highlights#8c6717 / #f9fafb4.94:1AA pass (4.5:1)
  • Primary on backgroundUI component and large text#2563eb / #f9fafb4.95:1AA pass (3:1)

CSS variables

:root {
  --color-background: #f9fafb;
  --color-surface: #eff1f5;
  --color-text: #161b27;
  --color-primary: #2563eb;
  --color-primary-text: #ffffff;
  --color-accent: #8c6717;
}

Tailwind v4 theme

@theme {
  --color-background: #f9fafb;
  --color-surface: #eff1f5;
  --color-text: #161b27;
  --color-primary: #2563eb;
  --color-primary-text: #ffffff;
  --color-accent: #8c6717;
}

How does the accessible palette generator work?

The generator reads the hue, saturation and lightness of your brand HEX. It keeps the brand colour as the primary role, then derives a near-white background and surface from the same hue, a dark text colour, and a complementary accent. The accent is darkened until it reaches 4.5:1 against the background, while the primary stays exactly as supplied so you can see whether the real brand colour passes.

Contrast is calculated with the WCAG relative luminance formula, not estimated by eye. A ratio runs from 1:1 for two identical colours to 21:1 for black on white. The pair results use the generated HEX values shown in the swatches above.

Which text and background pairs are tested?

Five pairs cover the roles a small interface needs: body text on the page background, body text on a surface, the button label on the primary colour, accent text on the background, and the primary colour as a UI element on the background. The first four use the 4.5:1 normal-text threshold. The last uses the 3:1 threshold for UI components and large text.

PairWCAG AA minimum
Body text on background4.5:1
Body text on surface4.5:1
Button label on primary4.5:1
Accent text on background4.5:1
Primary on background3:1

What should you do when a pair fails WCAG AA?

Change the foreground or the background, not the threshold. Darken a light text colour, lighten a dark background, or pick a deeper shade of the same brand hue. The palette contrast fixer lets you adjust either colour and copy the passing values. To test a whole palette at once, use the palette accessibility checker. For real website colour schemes that already pass, browse accessible website color palettes.

A passing pair is not a whole-site accessibility audit. Hover, focus and disabled states, text over images, keyboard access, alternative text and the other WCAG criteria still need their own checks.

Accessible palette generator FAQ

What does the accessible palette generator do?

It takes one brand HEX colour and builds a compact UI palette with background, surface, text, primary and accent roles. It then calculates the WCAG contrast ratio for the text and background pairs in that palette and marks each pair as an AA pass or fail.

Which contrast ratio does WCAG AA require?

WCAG 2.2 level AA asks for at least 4.5:1 between normal text and its background. Large text and UI components need at least 3:1. The results table states the threshold used for each pair.

Why does a generated pair still fail WCAG AA?

The primary colour is kept exactly as your brand HEX, so a light brand colour can fail when it is used as a UI element on a light background. The failing row is marked clearly and links to the palette contrast fixer so you can adjust the pair.

Can I use the palette in CSS or Tailwind?

Yes. Copy the CSS variables block and paste it into your stylesheet, then reference the background, surface, text, primary and accent variables in your components. The HEX values are also copyable from each swatch.

More color tools

Image tools

CSS generators

Image & SVG tools

Typography & units

More free tools

All free tools