-
Notifications
You must be signed in to change notification settings - Fork 306
feat: theme high contrast #734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
@fauxparse Hi! Can you review this changes? |
lucasmotta
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea, but can we keep only the :where([data-high-contrast="true"]) selector?
I see the .more-contrast may be provided by next-themes, but since that's not merged yet we can add this back later if needed.
|
@lucasmotta I believe it’s a good idea to establish a consistent API for themes and contrasts from the beginning. Both can be accessed by modifying the class of the body tag. Additionally, I’ve separated the next-contrast and next-themes. They’re still in the same repository but under different npm packages, allowing me to release them promptly without merging a PR. In my opinion, it’s more practical to maintain the class toggle for contrast. |
|
I hear you! The only part I'm not sure is to introduce another naming convention in our library: |
|
@lucasmotta okay, I will change it to |
|
@lucasmotta I have resolved your issue. Would you like to proceed with merging PR? |
Description
To improve accessibility and better support users with visual impairments, this PR introduces first-class support for high contrast themes. According to accessibility guidelines, high contrast modes are essential for many users, and making them easier to enable and manage significantly improves usability and inclusiveness.
Changes
[data-high-theme="true"]and the.high-contrastclass are applied. This allows developers to check the contrast state in CSS or toggle it using external libraries—similar to the existing.lightand.darkclass mechanisms.Testing steps
Open playground and try to toggle high contrast or copy theme
Critical moment: if you enable global high contrast you can not turn it off for individual component
Relates issues / PRs
Add the same functionality to next-themes pacocoursey/next-themes#360 to toggle contrast value using
.high-contrastclass in SSR-friendly way and including supportprefers-contrast:moremedia queryIn future step, after this PR will be merged I will update radix-ui docs to add info about this functional
After next-theme PR will be merged and released I will add an example how it works in playground