Tabs
The Tabs component is used for navigating frequently accessed, but distinct categories.
Accessibility
tab,shift + tab- to move focus between tabs.SpaceorEnter- to display the selected tab's contentaria-selected,aria-disabledare applied to the tabs.- Roles:
role=tab,role=tablist,role=tabpanel
Examples
Overrides
Additionally, you can fully customize any part of the Tabs through the overrides prop. The Tabs consists of multiple subcomponents that are listed bellow and you can override each one of them. To help you identify the names of these subcomponents, you can highlight them through this selector:
Note: You should always use longhand CSS properties. Mixing shorthands and longhands will lead into strange behaviors!
API
Tabs API
children ChildrenArray<Element<any>> required
An array of Tab components. eslint-disable-next-line flowtype/no-weak-types
ChildrenArrayElementanyactiveKey Key required
Key of the the tab to be selected.
Keydisabled boolean = false
If set to true all its tabs will be disabled
onChange function = () => undefined
Change handler that is called every time a new tab is selected
activeKey required Key => mixedorientation $Values<typeof ORIENTATION> =
Sets the orientation of the Tab component
$Values{ horizontal: "horizontal", vertical: "vertical" }renderAll boolean = false
Renders all tab content for SEO purposes regardless of tab active state
overrides { Root: { component: ?ComponentType<<T> & { children: Node }>, props: ?{} | ({}) => ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T> & { children: Node }><<T>>, TabBar: { component: ?ComponentType<<T> & { children: Node }>, props: ?{} | ({}) => ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T> & { children: Node }><<T>>, TabContent: { component: ?ComponentType<<T> & { children: Node }>, props: ?{} | ({}) => ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T> & { children: Node }><<T>> }<$Diff<object, object>> = {}
{ Root: { component: ?ComponentType<<T> & { children: Node }>, props: ?{} | ({}) => ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T> & { children: Node }><<T>>, TabBar: { component: ?ComponentType<<T> & { children: Node }>, props: ?{} | ({}) => ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T> & { children: Node }><<T>>, TabContent: { component: ?ComponentType<<T> & { children: Node }>, props: ?{} | ({}) => ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T> & { children: Node }><<T>> }$Diff$disabled boolean $active boolean $orientation $Values{ horizontal: "horizontal", vertical: "vertical" }, $active nullable booleanStatefulTabs API
initialState object
Initial state of the component
activeKey required KeystateReducer function = (type, newState) => undefined
A state change handler.
function $Keys{ change: "change" }, activeKey required Key, activeKey required Key => activeKey required KeyTab API
children Node
Nodedisabled boolean = false
Sets the tab to disabled
active boolean
key Key
Unique key for the tab. Defaults to the child index.
KeyonClick function = () => undefined
onClick handler for the Tab element
Event => mixedonKeyDown function = () => undefined
onKeyDown handler for the Tab element
KeyboardEvent => mixedonSelect function = () => undefined
onSelect handler for the Tab element
() => mixedoverrides { Tab: { component: ?ComponentType<<T> & { children: Node }>, props: ?{} | ({}) => ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T> & { children: Node }><<T>> }<object>
{ Tab: { component: ?ComponentType<<T> & { children: Node }>, props: ?{} | ({}) => ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T> & { children: Node }><<T>> }$disabled boolean $active boolean $orientation $Values{ horizontal: "horizontal", vertical: "vertical" }title Node = ""
Title of the Tab to be shown in the Tab bar
Nodeid string
$orientation $Values<typeof ORIENTATION>
$Values{ horizontal: "horizontal", vertical: "vertical" }Tabs exports
You can import this module like so:
import {Tabs} from 'baseui/tabs'
It exports the following components or utility functions:
- Tabs
- StatefulTabs
- Tab
- ORIENTATION
- STATE_CHANGE_TYPE
- StyledRoot
- StyledTab
- StyledTabBar
- StyledTabContent