Skip to content

[button] The Button Component #2138

Description

@ChrisCates

Feature request

Summary

Love the project, keen on integrating it on my workflows. Thus, reaching out about adding a Button component to base-ui that is fully WAI-ARIA compliant.

Please give feedback on the requirements spec I provided, or, just close this issue if you're already in progress for pushing Buttons to the library.

References

The WAI-ARIA Authoring Practices Guide provides a detailed example of how to implement an accessible button: Button Pattern

Motivation

I am not 100% sure what would meet your design philosophy, but, the following requirements spec is based on my assumptions of what would be ideal.

Requirements for the Base UI Button

Based on the WAI-ARIA specifications, the Button component should have the following:

  • Role: The button defaults to the role button.
  • Accessible Label: The button's accessible name should be computed from its text content. If there is no visible text, it should be provided via aria-labelledby or aria-label.
  • Description: If a description is present, it should be referenced using aria-describedby set to the ID of the description element.
  • Disabled State: When the button's action is unavailable, aria-disabled should be set to true.
  • Toggle Button State: For toggle buttons, aria-pressed should be used with values true (on) or false (off).
  • Menu Button Property: For menu buttons, aria-haspopup should be set to menu or true.
  • Keyboard Interaction: The button should be activatable with the Space or Enter keys. The focus behavior should depend on the type of action the button performs.
  • Default behaviour: The button should have default behaviour (ie: Enter, Esc) which can be flagged via a prop passed to the button or type.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: buttonChanges related to the button component.type: new featureExpand the scope of the product to solve a new problem.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions