Tabs
import { Tablist, Tab, TabPanel } from 'svogg-components';
Collection of tab components meant to be used in conjunction with each other.
Handles tab selection internally and encourages accessible implementations by requiring the
use of HTML id
attributes on tabs, which simultaneously works well with attribute such as
aria-controls
and aria-labelledby
.
Demo
Code
Spiders
Scorpions
Bats
🕷
TabList
Name | Type | Required | Default | Description |
---|---|---|---|---|
selectedTab | string | true |
| HTML `id` attribute of selected tab |
Tab
Name | Type | Required | Default | Description |
---|---|---|---|---|
selected | boolean | false | false | Tab selected state |
controls | (string | undefined) | false | - | HTML `aria-controls` attribute |
id | string | true |
| HTML `id` attribute |
Name | Detail | Type | Description |
---|---|---|---|
keydown | undefined | forwarded |
TabPanel
Name | Type | Required | Default | Description |
---|---|---|---|---|
labelledby | string | true |
| HTML `aria-labelledby` attribute |
active | boolean | false | false | Panel active state |
id | (string | undefined) | false | - | HTML `id` attribute |
CSS
Class | Description |
---|---|
.svogg-tablist | Applied to tablist |
.svogg-tab | Applied to tabs |
.selected | Applied to selected tab |
Keyboard navigation
- Tab
- When focus moves into the component, places focus on the active tab.
- If a tab has focus, moves focus to the next element in the document tab sequence. If panels are used, this would be the active tab panel.
- If a tab panel has focus, moves focus to the first focusable element within the panel, or moves focus to the next element in the document tab sequence.
- Shift + Tab
- When focus moves into the component, places focus on the active tab panel if panels are used, else moves focus to the active tab.
- If the active tab panel has focus, moves focus to the active tab.
- If a tab has focus, moves focus to the previous element in the document tab sequence.
- ← or →
- If a tab has focus, selects and moves focus to the next/previous tab.