Skip to main contentCarbon Design System

Button

How it works

The Button component is 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. Almost all interactions in the Carbon Design System are implemented using the native <button> element.

By default, interactive elements like <button> are included in the tab order of the document. When a button has focus, both the Space and Enter keys will activate the button. If the button is disabled, then the disabled attribute is provided.

The label for a button can be computed by the contents of the underlying <button>, or provided by the aria-label or aria-labelledby attributes. Additional information about the button may be supplied by the aria-describedby attribute.

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.

  1. The button can be activated using both the Space or Enter key.
  2. The button should have text or label that accurately describes the action of the button.
  3. 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.
  4. 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

Accessibility testing

Accessibility issues are tracked in the Carbon Design System GitHub repository.

Automated test

Automated test environmentResults
- macOS Mojave version 10.14.6 with VoiceOver
- 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
DAP test:
- No violations

macOS screen reader tests

Environment Results
- macOS Mojave version 10.14.6 with VoiceOver
- Chrome version 77.0.3865.90
- Carbon React version 7.7.1
VoiceOver(VO) test:
  1. Tab to the first button, VO announces, "The button label".
  2. Clicking the Enter or Space key activates the button.
- macOS Mojave version 10.14.6 with VoiceOver
- Safari version 13.0.2
- Carbon React version 7.7.1
VoiceOver(VO) test:
  1. Tab to the first button, VO announces, "The button label".
  2. Clicking the Enter or Space key activates the button.

Windows screen reader tests

EnvironmentResults
- Microsoft Windows 10
- Firefox version 67
- JAWS 19.1810.64
- Carbon React version 7.7.1
JAWS test:
  1. Tab to the first button, JAWS announces, "The button label".
  2. Clicking the Enter or Space key activates the button.
- Microsoft Windows 10
- Chrome Version 73.0.3683.68 (Official Build) (64-bit)
- JAWS Version 19.1810.64
- Carbon React version 7.7.1
JAWS test:
  1. Tab to the first button, JAWS announces, "The button label".
  2. Clicking the Enter or Space key activates the button.
- Microsoft Windows 10
- Chrome Version 73.0.3683.68 (Official Build) (64-bit)
- NVDA Version 2018.4.1
- Carbon React version 7.7.1
NVDA test:
  1. Tab to the first button, NVDA announces, "The button label".
  2. Clicking the Enter or Space key activates the button.

iOS screen reader tests

Environment Results
- iOS version 13.1.3 with VoiceOver
- Safari version 13.1.3
- Carbon React version 7.7.1
VoiceOver test:
  1. Tab to the first button, VO announces, "The button label".
  2. Clicking the Enter or Space key activates the button.

Android screen reader tests

Environment Results
- Android version 9 with Talkback
- Chrome version 72.0.3683.68 (Official Build) (64-bit)
- Carbon React version 7.7.1
Talkback test:
  1. Tab to the first button, Talkback announces, "The button label".
  2. Clicking the Enter or Space key activates the button.