Tabs
Usage
Controlled Tabs
Tabs.Tab accepts an optional tabKey prop, if included the tabKey will be included as second argument in the onTabChange callback:
Tabs with icons
Add any React node as icon by setting icon prop on Tabs.Tab component.
If icon prop is set, it is not necessary to pass label:
Change colors
Change color of individual tab by setting color property to Tabs.Tab component,
or change color of all tabs by setting color on Tabs component.
Color that you pass to these components should be defined in theme.colors.
Tabs position
Tabs controls position is controlled with grow and position props.
If grow property is set to true, controls will take 100% of available space
and position property is ignored.
Tab component props
In addition to icon and label props shown before,
Tab component accepts color, disabled and any other props from regular button (e.g. style, title, aria-, data-).
color prop will override color defined in Tabs component.
Add your styles with styles API
You can change styles of any element in button component with Styles API to match your design requirements.
To remove all default styles set variant prop to unstyled:
Get tab control ref
Accessibility and usability
Tabs component follows WAI-ARIA recommendations on accessibility:
- Use right and left arrow keys to change tabs when orientation is horizontal
- Use down and up arrow keys to change tabs when orientation is vertical
- Only selected tab control can be focused
- All elements have correct roles: tab, tablist and tabpanel
- aria-orientation is set based off
orientationprop (default is horizontal)