-
-
Notifications
You must be signed in to change notification settings - Fork 314
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
NEXT: Resolve global focus states for native elements and Zag-based components #2806
Comments
Noting a related bug here: React Ratings components cannot be tab focused when value is |
Ok, so here's a quick rundown of what I've discovered regarding Tailwind and focus states:
What I've done is go ahead and implement this pull request that does two things: /* Global Focus */
:focus {
@apply focus:outline-surface-950 dark:focus:outline-surface-50;
}
/* Focus Class (for components) */
.focused {
@apply ring-[2px] ring-surface-950 dark:ring-surface-50 ring-inset;
}
The result is more consistent focus styling across the board. Note that the global style does NOT fix the outline issue that appears in select browsers where you may see a double outline (neutral + system OS color outline). Present in in Chrome/Firefox, but not Safari. It merely modifies the outline using the system color to a fixed light/dark theme Surface color for light/dark mode. This results in what may look like a thicker outline depending on the colors - for example white + white. Here's a before vs after comparison... Before (default styles): After (modified): Note this affect is not present in Safari, which appears to overwrite and control focus state in unique fasion: Note the only two components that required manual intervention was the Segment Control and Switch. Other components use the global focus state because they use elements like |
The default approach does work in Safari. Also, since so many folks are using Tailwind these days, isn't the default behavior what users are used to? The default approach with the white and blue will work both on light and dark borders/backgrounds. While the I guess the question is: would the thicker outline that has one color be sufficient enough if it focuses a button that has the same color as background color? |
@bartduisters this is my concern as well. I'm tempted to drop the global style. However, we will have a hard requirement for the |
My suggestion would be to take over the Tailwind approach, it might be less visually pleasing. But to me, functionality/accessibility is more important when I'm doing keyboard navigation. I rather clearly see what is selected when tabbing and it being visually less pleasing, than the other way around. |
@bartduisters if you mean to default to Tailwind's default - then we definitely can for the global focus styles. But I don't think we replicate these for the component focus class. Those will likely never be in sync. I know you're on Discord atm, so we can bump this convo over there. |
Just a quick update - after reviewing on Discord we've decided to forego the global Currently we are still using the Furthermore, we may follow up with the Zag team in the near future and bring forth some of the pain points we're facing. See if they have any suggestions or are open to some suggestions for improvement in this regard. |
Following our recent integration of Zag.js, we've been alerted to the fact that our focus states styles are not consistent within Skeleton. Additionally, Zag handles focus state different than native elements. So we should review our options for providing a unified focus solution, ideally via a global style. Though we may need to replicate some focus states locally due to how Zag handles focus state with
data-focus
attributes.Goal
Resources
The text was updated successfully, but these errors were encountered: