Fix color-contrast in Tailwind CSS
In Tailwind CSS codebases, color-contrast failures overwhelmingly trace back to light neutral scales (text-slate-400, text-gray-400 on bg-white at 2.56:1) and vibrant 400-level button fills paired with text-white (bg-sky-400 at 2.14:1). Shifting body/muted copy to shade 600+ and white-text buttons to shade 700+ clears WCAG 2.2 AA 4.5:1 across every page.
Before and after
<!-- Broken Tailwind CSS: slate-400 on white (2.56:1) & white on sky-400 (2.14:1) -->
<div class="rounded-lg border border-slate-200 bg-white p-4">
<p class="mb-3 text-sm text-slate-400">
Free shipping on orders over $75 — ships within 24 hours.
</p>
<button
type="button"
class="rounded-md bg-sky-400 px-4 py-2 text-sm font-semibold text-white hover:bg-sky-500"
>
Add to Cart
</button>
</div><!-- Fixed Tailwind CSS: slate-600 on white (7.58:1) & white on sky-700 (5.93:1) -->
<div class="rounded-lg border border-slate-300 bg-white p-4">
<p class="mb-3 text-sm text-slate-600">
Free shipping on orders over $75 — ships within 24 hours.
</p>
<button
type="button"
class="rounded-md bg-sky-700 px-4 py-2 text-sm font-semibold text-white hover:bg-sky-800 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-700"
>
Add to Cart
</button>
</div>Fixed vs. broken example
Inspect the foreground and background colors in Chrome DevTools Color Picker to verify the live WCAG AA (4.5:1 normal text, 3:1 large text) contrast badges.
Playwright + axe-core check
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
test("Tailwind product card passes axe-core color-contrast", async ({ page }) => {
await page.goto("/pricing");
const results = await new AxeBuilder({ page })
.withRules(["color-contrast"])
.analyze();
expect(results.violations).toEqual([]);
});Template deduplication tip
A single muted utility class like text-slate-400 in a shared card, footer, or Tailwind @theme token can trigger hundreds of raw axe-core violations across /products/* and /blog/*. A11yDrift collapses those into one root template cluster so upgrading your semantic color token fixes the entire site in one PR.
Who this affects
Low-vision readers, older users with presbyopia, people with color-vision deficiencies, and anyone viewing a screen in bright sunlight struggle or fail to read muted gray captions, pale badges, and low-contrast CTA buttons.
NVDA & VoiceOver transcript
Screen readers announce the same copy for both versions; this rule primarily impacts low-vision readers, screen magnifiers, and visual legibility.
NVDA (Windows)
Screen readers still speak "Free shipping on orders over $75" and "Add to Cart, button", but screen magnifier and low-vision users cannot visually locate or read the faded copy and pale blue button.
Screen readers announce "Free shipping on orders over $75" and "Add to Cart, button", while sighted low-vision and ZoomText users clearly distinguish both the 7.58:1 body copy and 5.93:1 CTA.
VoiceOver (macOS / iOS)
VoiceOver speaks "Add to Cart, button", yet users combining VoiceOver with Zoom or macOS Increase Contrast experience severe glare washout on the 2.14:1 sky-blue fill.
VoiceOver speaks "Add to Cart, button", and the 5.93:1 darkened surface stays legible across macOS Zoom, mobile sunlight, and high-brightness displays.
Common questions
Which Tailwind gray/slate shades safely pass 4.5:1 on white?
Why do Tailwind bg-emerald-500 and bg-sky-500 fail with text-white?
How do I prevent Tailwind contrast regressions in CI?
Test a URL for color-contrast
Enter any public URL for a free WCAG 2.2 AA check—no account or credit card required.
Shipping Tailwind CSS weekly? Block new color-contrast regressions in PRs with our baseline-diff GitHub Action PR gate (≤20 URLs/PR).