Skip to content

[EuiButton] Disabled buttons are invisible to screen readers, creating a UX gap #5666

Closed
3 of 3 issues completed
Closed

Description

@1Copenut

Description

Our use of the HTML disabled attribute on buttons removes them from the accessibility tree, making them invisible to screen readers and keyboard users and preventing us from providing critical context to all users. We should use aria-disabled instead.

Problem to solve

Pervasive accessibility issue in EUI (and Kibana by extension)

Our buttons all use the HTML5 disabled attribute to remove buttons' default behavior.

As a user, seeing a button as disabled (rather than not at all) often provides critical context for users. They see it, so they know there is an option to take some action, but that action not possible right now.

For example, imagine a "Submit" button that is disabled. As a user, you'd see that button, now that you can take that "Submit" action, but it's not possible right now because there's something else you need to do first.

To further help provide that context, we often provide tooltips on those buttons that provide additional context. "This button is disabled because you need to do XYZ first.".

This is all useful context, all of which is invisible to screenreaders. They have no knowledge of the existence of that button or the additional context provided.

Image
<EuiToolTip
  position="top"
  content={<p>This button is disabled because you need to do XYZ first.</p>}
>
  <EuiButton disabled={true}>Submit</EuiButton>
</EuiToolTip>

Common point of friction for development teams

Teams often experience churn when they encounter this issue and find there's no current solution. Here's an example:
https://github.com/elastic/kibana-team/issues/1323

Current workarounds

One "workaround" (which is not really a feasible workaround) would be to not use disabled prop and apply all required handling manually as well as re-adding disabled styles.

Another could potentially be to add focusable wrappers with e.g. tooltips instead.

Examples in Kibana

Recent requests or related issues or discussions:

Slack threads

Proposed solution

To improve this behavior we want to replace the usage of the disabled attribute on button DOM elements with aria-disabled. This means:

  • the element is still announced in a disabled state to assistive technologies
  • the default behavior of disabled does not apply = the element has still all default events and behaviors

Because the default disabled behavior is removed, we'll need to manually ensure the element behaves as if it was disabled. This means:

  • ensuring no unwanted events are triggered (e.g. unsetting of mouse and key events)
  • ensuring the disabled styling is applied based on the prop disabled not the DOM attribute via the selector :disabled
  • adjust all test cases that check disabled states

Considerations

  1. Based on the amount of different components that would benefit from this update (within EUI as well as on consumer side) we should consider providing a sharable solution (e.g. a hook) to provide the "set-as-disabled" functionality.

  2. Updating a basic attribute like disabled might result in a lot of broken tests depending on testing framework and how those handle the check for "isDisabled". It would be wise to run tests/CI early with an early PoC to gage the impact and potential issues early on.

    • ⚠ Testing-library's toBeDisabled does not include aria-disabled (issue)
    • ⚠ Selenium uses isEnabled to check for disabled elements (docs) which only checks for the disabled attribute (code)
    • ⚠ Cypress checks disability based only for the disabled attribute (docs)
    • 💭 We might want to consider providing new testing helpers and/or a combined one that checks disabled and aria-disabled together

Components that use <button> elements with disabled attribute

ℹ This list includes exported components as well as internal ones that are subcomponents of exported components.

  • EuiButton
  • EuiButtonEmpty
  • EuiButtonIcon
  • EuiBadge
  • EuiCard
  • EuiContextMenuItem
  • EuiColorPickerSwatch
  • EuiSuperDatePicker
  • EuiDatePopoverButton
  • EuiFilterSelectItem
  • EuiFormControlLayoutClearButton
  • EuiFormControlLayoutCustomIcon
  • EuiRangeThumb
  • EuiTickValue
  • EuiSuperSelectControl
  • EuiSwitch
  • EuiImageButton
  • EuiLink
  • EuiListGroupItem
  • EuiPanel
  • EuiResizableButton
  • EuiSelectableListItem
  • EuiSideNavItem
  • EuiStepHorizontal
  • EuiTab
  • EuiTreeViewItem

Some relevant research

WCAG guidance

Historical context

@miukimiu brought up a great question in #5649 with her comment about the isLoading behavior:

To introduce a EuiButtonIcon isLoading state I can follow the other buttons isLoading state approach:

  • The button gets disabled.
  • The EuiIcon gets replaced with a EuiLoadingSpinner.
  • We introduce a new size to EuiLoadingSpinner "XXL" so that all the sizes match the EuiIcon sizes.

But I have some a11y questions.

  • When the button gets disabled the focus state is missed.
  • It gets removed from the accessibility tree and is invisible to assistive technology users

So when the EuiButtonIcon isLoading would adding an aria-disabled instead of disabled be more appropriate? Or is it OK to keep following the other buttons' pattern?

Sub-issues

Sub-issues

3 of 3 Issues completed
Loading 3 sub-issues

Activity

  1. chandlerprall commented on Mar 2, 2022

    @chandlerprall
    Contributor

    👍 If we decide to implement aria-disabled instead of disabled in some cases, we'll need to prevent onClick and possibly other events from firing.

  2. elizabetdev commented on Mar 3, 2022

    @elizabetdev
    Contributor

    The following article is also interesting to add to @1Copenut's relevant research list: Making Disabled Buttons More Inclusive.

  3. changed the title [-][EuiButton] Review the `isLoading` prop behavior for screen reader experience[/-] [+][EuiButton] Review the `isLoading` and `isDisabled` prop behavior for screen reader experience[/+] on Apr 8, 2022
  4. github-actions commented on Oct 5, 2022

    @github-actions

    👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.

  5. added
    stale-issue
    on Oct 5, 2022
  6. added and removed
    stale-issue
    on Oct 5, 2022
  7. 1Copenut commented on Oct 25, 2022

    @1Copenut
    ContributorAuthor

    Another discussion of this point, on Material UI: mui/material-ui#14455

  8. cee-chen commented on Jan 30, 2023

    @cee-chen
    Contributor

    #4797 Should be handled at the same time

  9. github-actions commented on Oct 22, 2023

    @github-actions

    👋 Hi there - this issue hasn't had any activity in 6 months. If the EUI team has not explicitly expressed that this is something on our roadmap, it's unlikely that we'll pick this issue up. We would sincerely appreciate a PR/community contribution if this is something that matters to you! If not, and there is no further activity on this issue for another 6 months (i.e. it's stale for over a year), the issue will be auto-closed.

  10. added
    stale-issue
    on Oct 22, 2023
  11. 26 remaining items

  12. JasonStoltz commented on Sep 11, 2025

    @JasonStoltz
    Contributor

    Just noted that this issue came up again, today in Slack.

    User: "possible to display tooltip on basic table icon actions?"
    Us: "It's possible with the description property on DefaultItemAction. The tooltip is rendered when enabled = true . Let me know if that's what you need.
    User: "but what we do if we want to show tooltip to tell why button is disabled?
    Us: "his is a long standing topic and a frequent question we get. From accessiblity point of view, it's not possible to display a tooltip on a disabled button because disabled buttons are not focusable. We have this issue on this quarter roadmap which you can track: #5666. We know it's pain right now"
    User: "Yeah but we have a tooltip wrapped disabled buttons everywhere in kibana"

  13. mgadewoll commented on Oct 2, 2025

    @mgadewoll
    Contributor

    ℹ️ Another related issue:
    The usage of isLoading adds the disabled attribute which results in removed focus and prevents the blur event from being fired. This leads to the tooltip being stuck on the button as the state wasn't triggered on blur.

  14. JasonStoltz commented on Dec 15, 2025

    @JasonStoltz
    Contributor

    @mgadewoll Closing this as we delivered #9201 in https://github.com/elastic/eui/releases/tag/v109.1.0 and I don't believe we're planning to do any more here for the time being.

    Feel free to re-open if we still need this issue.

  15. mgadewoll commented on Dec 16, 2025

    @mgadewoll
    Contributor

    @mgadewoll Closing this as we delivered #9201 in https://github.com/elastic/eui/releases/tag/v109.1.0 and I don't believe we're planning to do any more here for the time being.

    Feel free to re-open if we still need this issue.

    @JasonStoltz Thanks. That's fine. We might want to get back to #8869 eventually. But it makes sense to give the disabled button functionality some time to be tested and used while in Beta state first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions