Repository navigation
fix(a11y): add destructive-muted-foreground so error descriptions meet WCAG AA - #94
Open
navajyoth-puthalath13 wants to merge 1 commit into
Conversation
…t WCAG AA The destructive Alert and Attachment error descriptions are meant to sit quieter than the title. That quietness came from opacity (/90, /80), which lightened red-600 below 4.5:1 (4.49 and 4.11 in light, 4.37 in dark). Add a red text token, --destructive-muted-foreground: the destructive red at 90% chroma, keeping its lightness and hue. It's a solid colour, so the description stays a little quieter than the title while contrast holds (4.85:1 light, 6.30:1 dark). High contrast uses red-700 / red-300 and protanopia uses yellow-800 / yellow-300. Both descriptions use it. --destructive, titles, icons, borders and buttons are unchanged. Document the token on the Colors page. Closes ohcnetwork#93 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #93
The intent
In the destructive Alert and the Attachment error state, the description is designed to sit quieter than the title. The title says what went wrong; the description is supporting detail. This PR keeps that hierarchy.
The problem
The quietness came from opacity:
text-destructive/90(Alert) andtext-destructive/80(Attachment). Opacity makes text see-through, so the red gets lighter.--destructive(red-600) only passes on white at 4.76:1, so the faded text fell below WCAG AA's 4.5:1:The Alert gap is tiny and hard to see by eye, but WCAG doesn't round, and these are error messages the user needs to read.
The solution
Keep the red's lightness and hue, and lower only its saturation to 90%. Contrast depends on lightness, so it holds. The colour is solid, so it doesn't depend on the background. And the description still reads a little quieter than the title.
New token:
--destructive-muted-foreground, the red counterpart of--muted-foreground:oklch(from var(--color-red-600) l calc(c * 0.9) h)(≈ #de2022)oklch(from var(--color-red-400) l calc(c * 0.9) h)(≈ #f86c6d)var(--color-red-700)var(--color-red-300)var(--color-yellow-800)var(--color-yellow-300)Tritanopia inherits the light and dark values.
What changed
src/index.css: the token in:root,.dark, both high-contrast blocks and both protanopia blocks, plus the@theme inlinemappingalert.tsx:text-destructive/90→text-destructive-muted-foregroundattachment.tsx:text-destructive/80→text-destructive-muted-foregroundcolors-page.tsx: the token documented in the Text swatches, the Pairings table and the High Contrast notepublic/registry/…/alert.json,attachment.json: regeneratedUnchanged:
--destructive, titles, icons, borders, rings, buttons, menus, font weight and size.Why a new token: structure for the destructive colours
Before this PR, one token (
--destructive) did every red job: borders, rings, tinted backgrounds, icons, titles and descriptions. Grey text has a structure (foreground,muted-foreground,soft-foreground); red didn't, so the descriptions improvised with opacity. This adds the missing text level:--destructive--destructive-muted-foreground(new)--destructivecan't silently break it..claude/skills/better-colors: solid colour for text, one token per role. It's built from a palette token with relative colour, asbubble.tsxalready does (oklch(from var(--primary) 0.93 calc(c*0.4) h)). For Figma, the values are #de2022 (light) and #f86c6d (dark).How I tested it
I compared the original and the new version in Storybook using a switch between the two, in light and dark mode, to make sure the description still reads as quieter than the title. axe reports no
color-contrastviolations on the Alert or Attachment examples in light mode, and I verified the dark-mode values by calculation. Lint, format, typecheck,registry:checkand build pass.Notes
muted-background(4.44) or on red tints (4.06), and neither component uses those.cssVars) so installs get it?🤖 Generated with Claude Code