-
Notifications
You must be signed in to change notification settings - Fork 21
Update buttons to be more accessible #1292
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| addVariant('children', '& > *') | ||
| addVariant('between', '& > * + *') | ||
| addVariant('selected', '.is-selected &') | ||
| addVariant('disabled', '&.visually-disabled, &:disabled') |
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.
🔥
| e.stopPropagation() | ||
| e.preventDefault() | ||
| } | ||
|
|
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.
Love this. Hope we don't find this breaks some other click behavior in the container.
david-crespo
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.
Great!
Co-authored-by: David Crespo <david-crespo@users.noreply.github.com>
disabledbuttons have a bit of an accessibility problem in that they can't be tabbed to. While they technically still show up in the accessibility tree, they're often effectively invisible when many screen readers rely on tabbing behavior to announce UI elements.This PR alters the
button'sdisabledprop to add avisually-disabledclass instead of thedisabledattribute. When thedisabledprop is present it turns theonClickandonMouseDownprops to no-ops. To preserve the styling I've overridden the defaultdisabledtailwind to support both thedisabledpseudo selector and thevisually-disabledclass.Follow-ups
Once #1288 is merged I'm going to follow up with an update to make it easier to attach tooltips to elements and add a
disabledReasonprop to the button to be able to invoke a tooltip to say why a button is disabled.