Skip to content

A11y: add attribute hints for role="tab" and role="tabpanel" #13226

Open
@theetrain

Description

@theetrain

Describe the problem

It would be nice to have a11y hints when constructing a tabbed interface via role="tab" and role="tabpanel".

Describe the proposed solution

Complete example: https://svelte.dev/repl/cb3364c7b97842be901b42dd2d597fe5?version=4.2.19

Requirements to satisfy role="tab":

  • Tab must include aria-controls that match the id of its respective tab panel.
  • Tab must include aria-selected to indicate selected tab.
  • Tab must include onkeydown event listener such that left and right arrow keys can switch between tabs (up to the developer whether to immediately select tab upon switch); and up and down arrow keys should blur focus and scroll up or down the page respectively.
  • If element containing role="tab" is inherently non-interactive, it must include necessary attributes for keyboard accessibility or switch to an interactive element such as <button> or <input type="radio" />

Requirements to satisfy role="tabpanel":

  • Tab panel must include aria-labelledby to match the id of its respective tab.
  • Panel must include tabindex="0" to ensure it is the next focusable element after tabs.

Reference: https://www.w3.org/WAI/ARIA/apg/patterns/tabs/

Importance

nice to have

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions