Button
How it works
The Carbon button components are used to trigger an action or event, such as submitting a form, opening a modal, canceling an action, or performing an add or delete operation. The button uses tabindex="0"
to ensure it is in the tab order. When the button has focus, Space
key as well as Enter
key activates the button. A button identified as disabled has aria-disabled
set to true and is ignored in the tab order. By default, the button’s accessible name is computed from any text content inside the button element.
Accessibility considerations
This component has been validated to meet the WCAG 2.1 AA and Section 508 accessibility guidelines, however changes made by the content owner can affect accessibility compliance. Be sure to review and follow the guidance in this section when updating or adding new content to this component.
- The button can be activated using both the
Space
orEnter
key. - The button should have text or label that accurately describes the action of the button.
- If a description of the button’s function is present, the button element should have an
aria-describedby
set to the ID of the element containing the description. - After the button is activated ensure the focus is set correctly based on the type of action the button performs. See W3C WAI-ARIA Authoring Practices Button Design Pattern for a list of examples.
Resources
- W3C WAI-ARIA Authoring Practices Button Design Pattern covers the usage of ARIA names, state and roles, as well as the expected keyboard interactions.
- IBM Accessibility Checklist Checkpoint:
- 2.4.7 Focus Visible (WCAG Success Criteria 2.4.7)
- 3.2.2 On Input (WCAG Success Criteria 3.2.2)
Accessibility testing
Accessibility issues are tracked in the Carbon Component GitHub repository.
Automated test
- Chrome version 77.0.3865.90
- Dynamic Assessment Plugin (DAP) version 1.8.0.0 - IBM Accessibility WCAG 2.1 Sept. 2019 Ruleset
- Carbon React version 7.7.1
- No violations
macOS screen reader tests
- Chrome version 77.0.3865.90
- Carbon React version 7.7.1
- Tab to the first button, VO announces, "The button label"
- Clicking the Enter or Space key activates the button
- Safari version 13.0.2
- Carbon React version 7.7.1
- Tab to the first button, VO announces, "The button label"
- Clicking the Enter or Space key activates the button
Windows screen reader tests
- Firefox version 67
- JAWS 19.1810.64
- Carbon React version 7.7.1
- Tab to the first button, JAWS announces, "The button label"
- Clicking the Enter or Space key activates the button.
- Chrome Version 73.0.3683.68 (Official Build) (64-bit)
- JAWS Version 19.1810.64
- Carbon React version 7.7.1
- Tab to the first button, JAWS announces, "The button label"
- Clicking the Enter or Space key activates the button.
- Chrome Version 73.0.3683.68 (Official Build) (64-bit)
- NVDA Version 2018.4.1
- Carbon React version 7.7.1
- Tab to the first button, NVDA announces, "The button label"
- Clicking the Enter or Space key activates the button.
iOS screen reader tests
- Safari version 13.1.3
- Carbon React version 7.7.1
- Tab to the first button, VO announces, "The button label"
- Clicking the Enter or Space key activates the button.
Android screen reader tests
- Chrome version 72.0.3683.68 (Official Build) (64-bit)
- Carbon React version 7.7.1
- Tab to the first button, Talkback announces, "The button label"
- Clicking the Enter or Space key activates the button.