Fix shadcn dark-mode text contrast while keeping brand colors
When helper text looks readable on the page but fades into a card, check both surfaces before changing the shared text token. ColorBox takes the current foreground and up to eight fixed backgrounds. It returns a suggested foreground and the contrast ratio on each surface before and after the change.
Repair muted text in globals.css
In this example, --muted-foreground is #666666 in dark mode. It appears on a #0f0f0f page and a #242424 card. Use a browser or curl to send these three color values.
curl 'https://colorbox.io/api/repair-text-contrast?foreground=666666&backgrounds=0f0f0f,242424'Run the two-background repair and see the JSONThe suggested text color is #8b8b8b. Contrast on the page rises from 3.34 to 5.63. On the card it rises from 2.70 to 4.56. Both pass the 4.5 threshold for normal text. For this theme the entire CSS change is one declaration inside .dark.
.dark {
- --muted-foreground: #666666;
+ --muted-foreground: #8b8b8b;
}Use the result in another app
Read the resolved colors in the target mode. Send six-digit hex colors or URL-encoded opaque, in-gamut OKLCH literals. An OKLCH foreground produces an OKLCH suggestion. Include each background where the text appears. Keep locked brand foregrounds out of the repair workflow. Use the read-only contrast check to audit those pairs.
For a pasteable CSS declaration, supply the token name as token=--muted-foreground. Add verify=1 for a check URL per surface. Resolve each URL against the API origin and fetch it to verify the emitted color before editing the stylesheet.
A repaired response includes the suggested hex color. unchanged means the original already passes every supplied background. blocked means the lightness search found no passing candidate and the suggestion is null. In that case, review whether the surfaces need separate text tokens.
Review the patch in the running app in both modes. Gradients, transparency, and component overrides can change the colors users actually see.