equinor / design-system

The Equinor design system
MIT License
119 stars 63 forks source link

Toggle Button #2450

Closed martalalik closed 1 year ago

martalalik commented 2 years ago

Goals

Research

Requirements

  1. Materials:

Variants:

  1. Exclusive selection - With exclusive selection, selecting one option deselects any other. Exclusive selection does not enforce that a button must be active.

  2. Multiple selection - Multiple selection allows for logically-grouped options, to have multiple options selected.

  3. Vertical buttons.

  4. Enforce value set - If you want to enforce that at least one button must be active.

  5. Custom - customise the component.

  6. With Menu Screenshot 2022-08-25 at 10 03 35

  7. In TopBar.

  8. Text only.

  9. Icon only.

  10. Text & icon.

Accessibility:

  1. ARIA - ToggleButtonGroup has role="group". You should provide an accessible label with aria-label="label", aria-labelledby="id"or <label>. ToggleButton sets aria-pressed="<bool>" according to the button state.You should label each button with aria-label.
  2. Keyboard - Navigate between buttons with the tab key. The button behaviour follows standard keyboard semantics.

Practice:

Additional info:

martalalik commented 2 years ago

Meeting 29.09

Variants:

  1. Exclusive selection.
  2. Multiple selection.
  3. Vertical buttons.
  4. Enforce value set.
  5. Custom.
  6. In TopBar.
  7. Text only.
  8. Only text.
  9. Text & icon.

Implementation checklist:

  1. Use <button> element, no links, with aria-pressed.
  2. Don’t change label and state together.

🤔

  1. BUTTON -> new ToggleButton based on Button with internal aria-pressed? 2. GROUP -> new ToggleButtonGroup based on ButtonGroup wrapper?
martalalik commented 2 years ago

1_X3iZ5B0n3AnV39lGIVbUIw

mimarz commented 1 year ago

Released in eds-core-react@0.22.0!