shadcnpreview
Guides

Accessible shadcn themes and WCAG color contrast

October 23, 2026 · 6 min read

A Shadcn UI theme is a set of CSS variables, and most of them come in pairs: a surface and the text that sits on it. If any of those pairs has too little contrast, some of your users won't be able to read the interface. The good news is that you only need to check a short list of pairs, and the rules are simple. This guide covers the WCAG thresholds, the token pairs that matter, and the cases that most often go wrong.

The WCAG contrast rules

WCAG 2 measures contrast as a ratio between two colors' relative luminance, from 1:1 (identical) to 21:1 (black on white). Level AA, the usual target, requires:

ContentMinimum ratio
Normal text4.5:1
Large text (about 24px regular, or about 18.5px bold)3:1
UI components and meaningful graphics (input borders, focus rings, icons that convey meaning)3:1

Level AAA raises text to 7:1 (4.5:1 for large text). It's a good goal for long-form reading, but AA is the common baseline for product UI.

Disabled controls and purely decorative elements are exempt, but don't rely on that. If users need to read it, it should pass.

The token pairs that matter

Shadcn UI names its tokens so that every surface has a matching foreground. Those pairs are exactly what you need to test:

Text tokenOn surfaceWhere you see it
--foreground--backgroundBody text, headings
--muted-foreground--backgroundDescriptions, helper text, placeholders
--muted-foreground--muted and --cardSecondary text inside cards, tabs, tables
--card-foreground--cardCard content
--popover-foreground--popoverMenus, dropdowns, tooltips
--primary-foreground--primaryPrimary buttons, badges
--secondary-foreground--secondarySecondary buttons
--accent-foreground--accentHovered and selected menu items
--destructive--backgroundError text and destructive buttons

For non-text contrast (3:1), also check --ring against --background for focus outlines, and --input or --border against --background where the border is the only thing that shows where an input is.

And then do all of it again in dark mode. Each preset defines a separate .dark set of variables, and a pair that passes in light mode can fail in dark mode, or the other way around.

A worked example: the Neutral base

Here are the light-mode values for the Neutral base color, and the contrast ratios they produce:

:root {
  --background: oklch(1 0 0);           /* white */
  --foreground: oklch(0.145 0 0);       /* ~19.8:1 on background */
  --primary: oklch(0.205 0 0);          /* ~17.9:1 on background */
  --muted-foreground: oklch(0.556 0 0); /* ~4.7:1 on background */
  --border: oklch(0.922 0 0);           /* ~1.3:1 on background */
}

A few things stand out:

  • Foreground text is far above the threshold. No concerns there.
  • Muted text passes, but with little margin. About 4.7:1 on white is fine. On a tinted surface like --muted or a slightly off-white card, it can drop below 4.5:1. Check it on every surface where you actually use it.
  • The border is very light. That's fine for decorative dividers and card edges. If an input field is identified only by its border, though, consider a stronger --input color or another visual cue.

Bright accents need dark foregrounds

The theme color sets --primary and --primary-foreground. With dark or saturated accents like blue, indigo, violet or red, the foreground is usually white or near-white. But some accents are very light: lime, yellow and amber in particular, and to a lesser degree cyan, sky and green.

Here's the Lime theme on the Mist base color, in light mode:

:root {
  --primary: oklch(0.841 0.238 128.85);
  --primary-foreground: oklch(0.405 0.101 131.063);
}

The primary is a bright lime, and the foreground is a dark olive green. That pair comes out at about 5.7:1, which passes AA. White text on the same lime would be about 1.5:1, which fails badly.

This has two practical consequences:

  1. Keep --primary-foreground dark if you customize a bright accent. Don't "fix" a lime button by switching its text to white.
  2. Don't use a bright primary as a text color on a light background. Lime text on white is around 1.5:1. Links, active tab labels and inline highlights in text-primary need a darker shade in light mode. In dark mode, the same bright color often works well as text.
Aa
ContinueCancelNew
you@example.com

Lime Kernel

Nova · Lime + Mist · Geist

b3QxdSH7R

Checking a theme step by step

  1. Get the CSS. Install the preset, or generate its variables with the preset decoder.
  2. List the pairs. Use the table above. Skip any token you don't use.
  3. Test each pair in light and dark mode. Run each pair through the contrast audit and note the ratio for both modes.
  4. Fix failures at the token level. Adjust lightness in the CSS variable, not in individual components, so the fix applies everywhere.
  5. Check real screens. Contrast is only part of the story. Look at small text sizes, placeholder text and text over images.

Start from a passing preset

If you'd rather not tune colors yourself, browse our accessible presets. Each one passes AA (4.5:1) on the key text pairs, including body text, muted text, buttons and destructive text, in both light and dark mode.

Common problems and fixes

Muted text that's too faint

Lower the lightness of --muted-foreground slightly in light mode (or raise it in dark mode) until it clears 4.5:1 on --muted and --card, not just on --background.

Accent text on light backgrounds

If you use the primary color for links or labels, add a darker variant for text, or use --foreground with an underline or icon to show interactivity.

Charts

Chart colors (--chart-1 to --chart-5) are a five-step ramp, and adjacent steps can be close in lightness. Don't rely on color alone. Add labels, patterns or a legend, and make sure each series is at least 3:1 against the chart background where it conveys meaning.

Destructive states

Red is often borderline for text in dark mode. Check --destructive against --background in both modes, not just against --primary-foreground.

Accessibility beyond contrast

Contrast is one part of accessibility. Shadcn UI components are built on accessible primitives with keyboard support and ARIA attributes, but you still need visible focus states (don't remove --ring), sensible heading order and labels on icon-only buttons. If you test with real layouts, the preset builder renders full pages from shadcnblocks components, which makes weak spots like faint captions or low-contrast badges easy to spot.

FAQ

Do Shadcn UI's default colors pass WCAG AA?

The core pairs in the Neutral base pass AA in light mode: foreground is about 19.8:1 and muted text about 4.7:1 on the background. Always recheck after changing the theme color, and check secondary surfaces and dark mode too.

Does WCAG work with oklch colors?

Yes. WCAG contrast is based on relative luminance, which can be calculated from any color format, including oklch(). If a token has transparency, blend it over the surface behind it before measuring.

Should I aim for AA or AAA?

AA (4.5:1 for text) is the standard target for most products and many legal requirements. Aim for AAA on long-form reading content if you can.

Is APCA better than WCAG 2 contrast?

APCA is a newer contrast model being explored for future guidelines. WCAG 2's ratios are what current standards reference, so test against them first.