Skip to main content
HomeComponentsTabs
warning
This is a beta release of the Quantum web libraries
Please be careful when using them in production, as they may contain bugs, unstable breaking changes, and incomplete features.

Tabs

Tabs organize content into multiple sections and allow users to navigate between them.

By default, Tabs will handle automatically the active tab item based on user interaction thanks to the enableAutoActive prop set by default to true.

info

All tab items and submenu items must have an id attribute for the features to work properly.

Basic tabs

A basic example with three tabs.

Item 1
Item 2
Item 3
<Tabs activeId="tab-item-1">
<Tab id="tab-item-1" label="Item 1"></Tab>
<Tab id="tab-item-2" label="Item 2"></Tab>
<Tab id="tab-item-3" label="Item 3"></Tab>
</Tabs>

Sizes

Set size attribute to small or medium to style tabs size. By default, tabs have size medium.

Item 1
Item 2
Item 3
<Tabs activeId="tab-item-1" size="small">
<Tab id="tab-item-1" label="Item 1"></Tab>
<Tab id="tab-item-2" label="Item 2"></Tab>
<Tab id="tab-item-3" label="Item 3"></Tab>
</Tabs>
Item 1
Item 2
Item 3
<Tabs activeId="tab-item-1" size="medium">
<Tab id="tab-item-1" label="Item 1"></Tab>
<Tab id="tab-item-2" label="Item 2"></Tab>
<Tab id="tab-item-3" label="Item 3"></Tab>
</Tabs>

Managing items

All the props listed below can be applied directly to the Tabs component.

info

All tab item elements must have an id for the features to work properly.

enableAutoActive

Setting the enableAutoActive prop to true (default value) will automatically activate the active state of tab menu items when they are clicked or when the activeId prop value has changed.

On the other hand, setting it to false will require manual management of the active state.

Item 1
Item 2
Item 3
<Tabs enableAutoActive={false}>
<Tab id="tab-item-1" label="Item 1"></Tab>
<Tab id="tab-item-2" label="Item 2" active></Tab>
<Tab id="tab-item-3" label="Item 3"></Tab>
</Tabs>

activeId

Set the activeId value to the active tab item id by default.

Item 1
Item 2
Item 3
<Tabs activeId="tab-item-2">
<Tab id="tab-item-1" label="Item 1"></Tab>
<Tab id="tab-item-2" label="Item 2"></Tab>
<Tab id="tab-item-3" label="Item 3"></Tab>
</Tabs>

Disabled State

Add disabled attribute to tab to style it as disabled.

Item 1
Item 2
Item 3
<Tabs>
<Tab id="tab-item-1" label="Item 1" disabled></Tab>
<Tab id="tab-item-2" label="Item 2"></Tab>
<Tab id="tab-item-3" label="Item 3"></Tab>
</Tabs>

Divider

By default, tabs has a divider. Alternatively, tabs can be used without a divider by setting divider to false.

Item 1
Item 2
Item 3
<Tabs divider={false}>
<Tab id="tab-item-1" label="Item 1"></Tab>
<Tab id="tab-item-2" label="Item 2"></Tab>
<Tab id="tab-item-3" label="Item 3"></Tab>
</Tabs>

Layout

  • fullWidth attribute if you want the tabs container to take up the whole width.
  • fullHeight attribute if you want the tabs container to take up the whole height.

Fluid Tabs

Add fullWidth and fluid to Tabs if you want set equal tabs widths when the tabs wrapper takes up the whole width available.

Item 1
Item 2
Item 3
<Tabs activeId="tab-item-1" fullWidth fluid>
<Tab id="tab-item-1" label="Item 1"></Tab>
<Tab id="tab-item-2" label="Item 2"></Tab>
<Tab id="tab-item-3" label="Item 3"></Tab>
</Tabs>

Alignment

Tabs alignment can be set by setting alignment attribute to left, center, right.

Left alignment

Item 1
Item 2
Item 3
<Tabs activeId="tab-item-1" fullWidth alignment="left">
<Tab id="tab-item-1" label="Item 1"></Tab>
<Tab id="tab-item-2" label="Item 2"></Tab>
<Tab id="tab-item-3" label="Item 3"></Tab>
</Tabs>

Center alignment

Item 1
Item 2
Item 3
<Tabs activeId="tab-item-1" fullWidth alignment="center">
<Tab id="tab-item-1" label="Item 1"></Tab>
<Tab id="tab-item-2" label="Item 2"></Tab>
<Tab id="tab-item-3" label="Item 3"></Tab>
</Tabs>

Right alignment

Item 1
Item 2
Item 3
<Tabs activeId="tab-item-1" fullWidth alignment="right">
<Tab id="tab-item-1" label="Item 1"></Tab>
<Tab id="tab-item-2" label="Item 2"></Tab>
<Tab id="tab-item-3" label="Item 3"></Tab>
</Tabs>

Scrollable tabs

Use scrollHorizontally to allow horizontal scrolling if needed.

Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
<Tabs activeId="tab-item-1" scrollHorizontally fullWidth>
<Tab id="tab-item-1" label="Item 1"></Tab>
<Tab id="tab-item-2" label="Item 2"></Tab>
<Tab id="tab-item-3" label="Item 3"></Tab>
<Tab id="tab-item-4" label="Item 4"></Tab>
<Tab id="tab-item-5" label="Item 5"></Tab>
<Tab id="tab-item-6" label="Item 6"></Tab>
<Tab id="tab-item-7" label="Item 7"></Tab>
</Tabs>

Icons

Tab labels may be either all icons or all text.

settings
account_circle
face
<Tabs activeId="tab-item-1">
<Tab id="tab-item-1" icon="settings"></Tab>
<Tab id="tab-item-2" icon="account_circle"></Tab>
<Tab id="tab-item-3" icon="face"></Tab>
</Tabs>
settingsItem 1
account_circleItem 2
faceItem 3
<Tabs activeId="tab-item-1">
<Tab id="tab-item-1" icon="settings" label="Item 1"></Tab>
<Tab id="tab-item-2" icon="account_circle" label="Item 2"></Tab>
<Tab id="tab-item-3" icon="face" label="Item 3"></Tab>
</Tabs>

Icon position

By default, the icon is positioned at the start of a tab. Other supported position is end.

settingsItem 1
Item 2account_circle
faceItem 3
<Tabs activeId="tab-item-1">
<Tab id="tab-item-1" icon="settings" label="Item 1" iconPosition="start"></Tab>
<Tab id="tab-item-2" icon="account_circle" label="Item 2" iconPosition="end"></Tab>
<Tab id="tab-item-3" icon="face" label="Item 3"></Tab>
</Tabs>

Vertical Tab

Set tabItemDirection attribute to horizontal or vertical to allow horizontal/vertical tab layout.

settingsItem 1
account_circleItem 2
faceItem 3
<Tabs activeId="tab-item-1" tabItemDirection="vertical">
<Tab id="tab-item-1" icon="settings" label="Item 1"></Tab>
<Tab id="tab-item-2" icon="account_circle" label="Item 2"></Tab>
<Tab id="tab-item-3" icon="face" label="Item 3"></Tab>
</Tabs>

Customization

A Tab can also take any content in their slot.

settings

Item 1

account_circle

Item 2

face

Item 3

<Tabs activeId="tab-item-1">
<Tab id="tab-item-1">
<Icon icon="settings" />
<Typography classes="text-green-500">Item 1</Typography>
</Tab>
<Tab id="tab-item-2">
<Icon icon="account_circle" />
<Typography classes="text-red-500">Item 2</Typography>
</Tab>
<Tab id="tab-item-3">
<Icon icon="face" />
<Typography classes="text-primary-500">Item 3</Typography>
</Tab>
</Tabs>

API

Tab

The Tab component accepts all the props a standard <div> does in React (HTML, ARIA, data attributes, event handlers, and children). Its props are typed as React.HTMLAttributes<HTMLDivElement>. See more about supported HTML props in React's documentation.

Loading API documentation...

Tabs

The Tabs component accepts all the props a standard <div> does in React (HTML, ARIA, data attributes, event handlers, and children). Its props are typed as React.HTMLAttributes<HTMLDivElement>. See more about supported HTML props in React's documentation.

Loading API documentation...

Spotted a bug, have a question, or want to suggest a new feature?

Submit an issue on GitLab