Accessible Tailwind color palette
One brand color, and a Tailwind 4 palette where text on every shade passes WCAG AA, in light and dark mode, unless you choose to keep your color exact.
Each step targets a fixed contrast against the background and comes with the text color that goes on top. If your color falls between two steps and misses AA, with text on top or against the background, you choose whether it stays exact or gets adjusted.
Large number: contrast of the text on the step; AA requires 4.5. Number below: the step against the background.
Light
#3B82F6 · exact at 500- Step 100. Dark text on top: 18.2 to 1. Against the background: 1.1 to 1.
- Step 200. Dark text on top: 16.1 to 1. Against the background: 1.2 to 1.
- Step 300. Dark text on top: 13.1 to 1. Against the background: 1.5 to 1.
- Step 400. Dark text on top: 9.4 to 1. Against the background: 2.1 to 1.
- Step 500, your color. Dark text on top: 5.3 to 1. Against the background: 3.7 to 1.
- Step 600. Light text on top: 5.3 to 1. Against the background: 6.0 to 1.
- Step 700. Light text on top: 7.6 to 1. Against the background: 8.5 to 1.
- Step 800. Light text on top: 10.7 to 1. Against the background: 12.0 to 1.
- Step 900. Light text on top: 14.2 to 1. Against the background: 16.0 to 1.
- Step 1000. Light text on top: 16.9 to 1. Against the background: 19.0 to 1.
Preview: button 5.3:1 link 6.0:1 border 3.7:1
Dark
#3B82F6 · exact at 600- Step 100. Light text on top: 18.4 to 1. Against the background: 1.0 to 1.
- Step 200. Light text on top: 17.1 to 1. Against the background: 1.1 to 1.
- Step 300. Light text on top: 14.7 to 1. Against the background: 1.3 to 1.
- Step 400. Light text on top: 10.6 to 1. Against the background: 1.8 to 1.
- Step 500. Light text on top: 5.6 to 1. Against the background: 3.4 to 1.
- Step 600, your color. Dark text on top: 5.1 to 1. Against the background: 5.5 to 1.
- Step 700. Dark text on top: 7.2 to 1. Against the background: 7.8 to 1.
- Step 800. Dark text on top: 10.2 to 1. Against the background: 11.0 to 1.
- Step 900. Dark text on top: 13.9 to 1. Against the background: 15.0 to 1.
- Step 1000. Dark text on top: 16.7 to 1. Against the background: 18.0 to 1.
Preview: button 5.6:1 link 5.5:1 border 3.4:1
Summary
Tailwind doesn't ship a text color for each step: you pick it and check it. Here every step comes with its own, and it reaches AA.
Text reaches AA on all 20 steps (minimum 5.1:1).
As a text color on the page: from 600. Borders and icons (3:1, WCAG AA): from 500.
How to use it
<button class="bg-brand-500 text-brand-500-contrast">Save</button>
<a class="text-brand-600">See details</a>
<div class="border border-brand-500">Changes saved</div>-contrast is the text color that goes on that step.
It reaches AA (4.5:1).
There's no 50 or 950: the scale goes from 100, the step closest to the background, to 1000, the farthest. In light mode 100 is the lightest; in dark mode, the darkest.
Export
/* Palette from #3b82f6, from taisho.design/en/tailwind-palette?c=3b82f6
Your color: step 500. Details at the end of the file. */
@theme {
--color-brand-100: oklch(0.9733 0.0126 259.81);
--color-brand-100-contrast: oklch(0.15 0 0);
--color-brand-200: oklch(0.9322 0.0323 259.81);
--color-brand-200-contrast: oklch(0.15 0 0);
--color-brand-300: oklch(0.8662 0.0655 259.81);
--color-brand-300-contrast: oklch(0.15 0 0);
--color-brand-400: oklch(0.7674 0.1184 259.81);
--color-brand-400-contrast: oklch(0.15 0 0);
--color-brand-500: oklch(0.6231 0.1880 259.81);
--color-brand-500-contrast: oklch(0.15 0 0);
--color-brand-600: oklch(0.5075 0.1880 259.81);
--color-brand-600-contrast: oklch(0.96 0 0);
--color-brand-700: oklch(0.4264 0.1692 259.81);
--color-brand-700-contrast: oklch(0.96 0 0);
--color-brand-800: oklch(0.3409 0.1370 259.81);
--color-brand-800-contrast: oklch(0.96 0 0);
--color-brand-900: oklch(0.2546 0.1023 259.81);
--color-brand-900-contrast: oklch(0.96 0 0);
--color-brand-1000: oklch(0.1772 0.0712 259.81);
--color-brand-1000-contrast: oklch(0.96 0 0);
}
/* Text on every step ≥ 4.5:1 (WCAG AA).
Measured against white. */
The engine behind this palette
This scale is the color engine of TaishoDS Core, an open-source (MIT) design system in HTML, CSS and JavaScript. It isn't a Tailwind plugin: it's an alternative, with its own classes. In the Core, components use the step that fits and dark mode comes built in. You don't need it to use this palette.
How it's calculated
- Each step targets a fixed contrast against the background: white in light mode, oklch(0.12 0 0) in dark mode.
- The text on each step is whichever of the two extreme Core grays has more contrast with it.
- Your color goes to the step its contrast points to. If it falls between two and misses AA, it is adjusted to the nearest one that reaches it, unless you choose to keep it exact.
- Against the background, AA is only asked of your color when it falls between two steps, whether it is adjusted or stays exact; the other steps have the contrast their place in the scale gives them.
- The figures for your color, when it falls between two steps and stays exact, are the worse of the unrounded color and the one the screen paints (8 bits).