As noted in #7879, there are three separate ways to disable a button:
disabled
aria-disabled
inactive
Our accessibility guidance generally discourages disabled because it makes buttons inaccessible by keyboard navigation, which may make them undiscoverable to screen readers. So I avoid this.
aria-disabled generally seems to work well, making buttons visually disabled while leaving them focusable and ensuring that screen reader users understand they are disabled. So I'm tempted to just reach for aria-disabled all the time.
However, there is also the inactive prop, and it's not clear why this exists or when we should prefer it over aria-disabled. Visually they are distinct, which makes inactive buttons visually inconsistent with other buttons. And inactive completely overrides variant. To be honest, inactive feels redundant, with limited functionality - I'm tempted to avoid it altogether.
There's a docs section on what an inactive button is:
An inactive Button is an accessible alternative to a disabled Button. They're intended to be used for buttons that are non-functional, but cannot be removed from the page.
Unlike a disabled Button, an inactive Button can respond to user input. For example, if a Button shows a tooltip when hovered or focused, or a Dialog when clicked.
But this just raises more questions than it answers - why would I use inactive if I can get exactly the same functionality from aria-disabled but with much better styling and variant support?
Possible solutions
Ideally we need to create explicit clarity around the correct way to disable buttons, without making consumers dig through several different docs to try and determine this for themselves.
I would propose the following:
- Deprecate and remove the
inactive prop in favor of aria-disabled
- Lint against the
disabled prop in favor of aria-disabled
- Document that
aria-disabled is the preferred approach
Alternatively, we could lean on inactive instead:
- Improve
inactive so that it works like aria-disabled, supporting variant styling
- Lint against
disabled and aria-disabled in favor of inactive
- Document that
inactive is the preferred approach
As noted in #7879, there are three separate ways to disable a button:
disabledaria-disabledinactiveOur accessibility guidance generally discourages
disabledbecause it makes buttons inaccessible by keyboard navigation, which may make them undiscoverable to screen readers. So I avoid this.aria-disabledgenerally seems to work well, making buttons visually disabled while leaving them focusable and ensuring that screen reader users understand they are disabled. So I'm tempted to just reach foraria-disabledall the time.However, there is also the
inactiveprop, and it's not clear why this exists or when we should prefer it overaria-disabled. Visually they are distinct, which makesinactivebuttons visually inconsistent with other buttons. Andinactivecompletely overridesvariant. To be honest,inactivefeels redundant, with limited functionality - I'm tempted to avoid it altogether.There's a docs section on what an inactive button is:
But this just raises more questions than it answers - why would I use
inactiveif I can get exactly the same functionality fromaria-disabledbut with much better styling andvariantsupport?Possible solutions
Ideally we need to create explicit clarity around the correct way to disable buttons, without making consumers dig through several different docs to try and determine this for themselves.
I would propose the following:
inactiveprop in favor ofaria-disableddisabledprop in favor ofaria-disabledaria-disabledis the preferred approachAlternatively, we could lean on
inactiveinstead:inactiveso that it works likearia-disabled, supporting variant stylingdisabledandaria-disabledin favor ofinactiveinactiveis the preferred approach