A component for toggling between related panels on the same page.
import { Tabs, TabList, Tab, TabPanel } from '@backstage/ui';
<Tabs>
<TabList>
<Tab id="tab1">Tab 1</Tab>
<Tab id="tab2">Tab 2</Tab>
</TabList>
<TabPanel id="tab1">Content 1</TabPanel>
<TabPanel id="tab2">Content 2</TabPanel>
</Tabs>Groups the tabs and the corresponding panels. Renders a <div> element.
| Prop | Type | Default | Responsive |
|---|---|---|---|
| orientation | horizontalvertical | horizontal | No |
| selectedKey | string | - | No |
| defaultSelectedKey | string | - | No |
| onSelectionChange | (key: Key) => void | - | No |
| isDisabled | boolean | false | No |
| disabledKeys | Iterable<Key> | - | No |
| children | ReactNode | - | No |
| className | string | - | No |
| style | CSSProperties | - | No |
An individual interactive tab button that toggles the corresponding panel. Renders a <button> element.
| Prop | Type | Default | Responsive |
|---|---|---|---|
| id | string | - | No |
| isDisabled | boolean | false | No |
| children | ReactNode | - | No |
| className | string | - | No |
| style | CSSProperties | - | No |
Here's how to set which tab is selected by default.
<Tabs defaultSelectedKey="tab2">
<TabList>
<Tab id="tab1">Tab 1</Tab>
<Tab id="tab2">Tab 2</Tab>
<Tab id="tab3">Tab 3</Tab>
</TabList>
<TabPanel id="tab1">Content 1</TabPanel>
<TabPanel id="tab2">Content 2</TabPanel>
<TabPanel id="tab3">Content 3</TabPanel>
</Tabs>Here's how to disable specific tabs.
<Tabs>
<TabList>
<Tab id="tab1">Tab 1</Tab>
<Tab id="tab2" isDisabled>Tab 2 (Disabled)</Tab>
<Tab id="tab3">Tab 3</Tab>
</TabList>
<TabPanel id="tab1">Content 1</TabPanel>
<TabPanel id="tab2">Content 2</TabPanel>
<TabPanel id="tab3">Content 3</TabPanel>
</Tabs>Here's how to display tabs vertically.
<Tabs orientation="vertical">
<TabList>
<Tab id="tab1">Tab 1</Tab>
<Tab id="tab2">Tab 2</Tab>
<Tab id="tab3">Tab 3</Tab>
</TabList>
<TabPanel id="tab1">Content 1</TabPanel>
<TabPanel id="tab2">Content 2</TabPanel>
<TabPanel id="tab3">Content 3</TabPanel>
</Tabs>Our theming system is based on a mix between CSS classes, CSS variables and data attributes. If you want to customise this component, you can use one of these class names below.
bui-Tabsbui-TabListbui-TabListWrapperbui-Tabbui-TabActivebui-TabHoveredbui-TabPanel0.9.0 - BREAKING: Changed className prop behavior to augment default styles instead of being ignored or overriding them.Affected components:
If you were passing custom className values to any of these components that relied on the previous behavior, you may need to adjust your styles to account for the default classes now being applied alongside your custom classes. #31496
0.8.0 - remove default selection of tab #312160.8.0 - Making href mandatory in tabs that are part of a Header component #313430.8.0 - Remove auto selection of tabs for tabs that all have href defined #312810.7.2 - Making href mandatory in tabs that are part of a Header component #313430.7.2 - Remove auto selection of tabs for tabs that all have href defined #312810.7.2 - remove default selection of tab #312160.4.0 - New Tabs component #29996