Tabs
Tabs are used to organize content by grouping similar information on the same page.Neutral selected states
When the platform-dst-tokens-finesse feature flag is enabled, this component uses the new neutral treatment for selected states.
Installation
| Install | yarn add @atlaskit/tabs |
|---|---|
| Source | Bitbucket.org, (opens new window) |
| npm | @atlaskit/tabs, (opens new window) |
| Bundle | unpkg.com, (opens new window) |
Props
Tabs props
| Description | Additional information to be included in the |
|---|---|
| Type | { [x: string]: any; } |
| Description | The children of Tabs. The first child should be a |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | You should not be accessing this prop under any circumstances.
It is provided by |
|---|---|
| Type | (payload: AnalyticsEventPayload) => UIAnalyticsEvent |
| Description | The index of the tab that will be selected by default when the component mounts. If not set the first tab will be displayed by default. |
|---|---|
| Type | number |
| Description | A unique ID that will be used to generate IDs for tabs and tab panels. This is required for accessibility purposes. |
|---|---|
| Type | string |
| Description | A callback function which will be fired when a changed. It will be passed
the index of the selected tab and a |
|---|---|
| Type | (index: number, analyticsEvent: UIAnalyticsEvent) => void |
| Description | No description. |
|---|---|
| Type | ((instance: any) => void) | RefObject<any> |
| Description | The selected tab's index. If this prop is set the component behaves as a
controlled component. It will be up to you to listen to |
|---|---|
| Type | number |
| Description | Tabs by default leaves |
|---|---|
| Type | boolean |
| Description | A |
|---|---|
| Type | string |
Tab props
| Description | The children to be rendered within a |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | A |
|---|---|
| Type | string |
Tab panel props
| Description | The children to be rendered within a |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | A |
|---|---|
| Type | string |
Hooks
useTab
useTab will return an object of type TabAttributesType.
| Description | The ID of the tab panel that this tab links. |
|---|---|
| Type | string |
| Description | The position of this tab within the tab list. |
|---|---|
| Type | number |
| Description | Whether this tab is selected. |
|---|---|
| Type | boolean |
| Description | The number of tabs in this tab list. |
|---|---|
| Type | number |
| Description | ID of the tab. |
|---|---|
| Type | string |
| Description | Changes the selected tab. |
|---|---|
| Type | () => void |
| Description | Allows navigation of tabs with automatic activation. Read here for more details: https://www.w3.org/TR/wai-aria-practices-1.1/examples/tabs/tabs-1/tabs.html |
|---|---|
| Type | (e: KeyboardEvent<HTMLElement>) => void |
| Description | Role is "tab". |
|---|---|
| Type | "tab" |
| Description | If the tab is selected the tab index is 0 and is focusable. Otherwise it is -1 and is not focusable. |
|---|---|
| Type | number |
useTabPanel
useTabPanel will return an object of type TabPanelAttributesType.
| Description | The id of the tab that links to this tab panel. |
|---|---|
| Type | string |
| Description | ID of the the tab panel. |
|---|---|
| Type | string |
| Description | Role is "tabpanel". |
|---|---|
| Type | "tabpanel" |
| Description | If the tab panel is selected the tab index is 0 and is focusable. Otherwise it is -1 and is not focusable. |
|---|---|
| Type | number |