Skip to main content

Components

Tabs

Tabs allow users to navigate between related sections of content, with only one section visible at a time. This is an effective way to organize and present related content on the same page.

value
Description

Controlled state for `Tabs` component

Type
string
Default
undefined
defaultValue
Description

Default selected tab value

Type
string
Default
undefined
onChange
Description

Callback with selected `TabItem` `value`

Type
(value: string) => void
Default
undefined
NameTypeDefaultDescription
valuestringundefined

Controlled state for `Tabs` component

defaultValuestringundefined

Default selected tab value

onChange(value: string) => voidundefined

Callback with selected `TabItem` `value`

TabsPanel

value
Description

When this value is selected as the current state, render this `TabsPanel` component. Must match the `value` of a `Tabs.Tab` component.

Type
string
NameTypeDefaultDescription
valuestring-

When this value is selected as the current state, render this `TabsPanel` component. Must match the `value` of a `Tabs.Tab` component.

TabsTab

value
Description

Unique value that will be set in the `Tabs` components state when the tab is activated

Type
string
NameTypeDefaultDescription
valuestring-

Unique value that will be set in the `Tabs` components state when the tab is activated

Use

Example

Icons only

In the example below, we have added Tooltip around Tabs.Tab to provide descriptive text for the icons.

Controlled

HTML

You can use u-tabs (u-elements.github.io), which is a web component that implements tabs. Add the class name ds-tabs.

We recommend using <u-tabs>, and not building your own tabs from scratch, to ensure good accessibility and functionality.

CSS variables and data attributes

CSS Variables
NameValue
--dsc-tabs-tab-paddingvar(--ds-size-3) var(--ds-size-5)
--dsc-tabs-tab-colorvar(--ds-color-neutral-text-subtle)
--dsc-tabs-tab-color--hovervar(--ds-color-neutral-text-default)
--dsc-tabs-tab-color--selectedvar(--ds-color-text-subtle)
--dsc-tabs-content-paddingvar(--ds-size-4) var(--ds-size-5)
--dsc-tabs-list-border-colorvar(--ds-color-neutral-border-subtle)
--dsc-tabs-list-border-bottom-widthvar(--ds-border-width-default)
--dsc-tabs-list-border-bottom-stylesolid

No relevant data attributes found.

Edit this page on github.com (opens in a new tab)