Tabs

size
disabled
import {TabProvider, TabList, Tab, TabPanel} from '@gravity-ui/uikit';

Tabs components is used to explore, organize content and switch between different views.

First Panel
Second Panel
Third Panel
<TabProvider value={activeTab} onUpdate={setActiveTab}>
    <TabList>
        <Tab value="first">First Tab</Tab>
        <Tab value="second">Active Tab</Tab>
        <Tab value="third" disabled>Disabled Tab</Tab>
    </TabList>
    <div>
        <TabPanel value="first">First Panel</TabPanel>
        <TabPanel value="second">Second Panel</TabPanel>
        <TabPanel value="third">Third Panel</TabPanel>
    </div>
</TabProvider>

Components

TabProvider

A component that provides the tab selection functionality

Properties

NameDescriptionTypeDefault
childrenList of tabs and tab panels, probably with some wrappersReact.ReactNode
valueActive tab valuestring
onUpdateUpdate tab handler(value: string) => void

TabList

Component that serves as the container for a set of tabs

Size

To control the size of the tabs use the size property. Default size is m.

<TabList value="second" size="m">
    <Tab value="first">M Size first</Tab>
    <Tab value="second">M Size second</Tab>
</TabList>

<TabList value="second" size="l">
    <Tab value="first">L Size first</Tab>
    <Tab value="second">L Size second</Tab>
</TabList>

<TabList value="second" size="xl">
    <Tab value="first">XL Size first</Tab>
    <Tab value="second">v Size second</Tab>
</TabList>

Properties

TabList accepts any valid div element props in addition to these:

NameDescriptionTypeDefault
childrenList of tabs, probably with some wrappersReact.ReactNode
valueActive tab valuestring
onUpdateUpdate tab handler(value: string) => void
classNameCSS-class of elementstring
activateOnFocusActivate tab on focus. Use this only if panel's content can be displayed immediatelybooleanfalse
sizeElement size"m" "l" "xl""m"
qaHTML data-qa attribute, used in testsstring

Tab

This component is used to render tab items.

Icon

Used if you need to display an icon for a tab item.

<TabList value="first">
    <Tab value="first" icon={<Icon size={16} data={GearIcon} />}>Tab with icon</Tab>
    <Tab value="second">Tab without icon</Tab>
</TabList>

States

Tab item has disabled flag.

<TabList value="first">
    <Tab value="first" >First Tab</Tab>
    <Tab value="second" disabled>Disabled Tab</Tab>
</TabList>

Counter

Used if you need to display a number for a tabs item.

<TabList value="first">
    <Tab value="first" counter={13}>First Tab</Tab>
    <Tab value="second" counter={3}>Second Tab</Tab>
</TabList>

Label

Used if you need to display a label for a tabs item.

<TabList value="first">
    <Tab value="first" label={{content: 'Label 1'}}>First Tab</Tab>
    <Tab value="second" label={{content: 'Label 2'}}>Second Tab</Tab>
</TabList>

Properties

Tab accepts any valid button or a element props in addition to these:

NameDescriptionTypeDefault
valueTab valuestring
titleTab titlestring
iconIcon displayed at the startReact.ReactNode
counterContent displayed at the endnumber string
hrefA URL to link to.string
label<Label> displayed at the endReact.ReactNode
disabledInactive stateboolean
componentOverrides the root componentReact.ElementType
childrenTab's contentReact.ReactNode
qaHTML data-qa attribute, used in testsstring

TabPanel

Is a container element for content associated with a tab

Properties

TabPanel accepts any valid div element props in addition to these:

NameDescriptionTypeDefault
childrenContent of panelReact.ReactNode
valueActive tab valuestring
qaHTML data-qa attribute, used in testsstring

CSS API

NameDescription
--g-tabs-border-widthTabs border width
--g-tabs-item-heightTabs item height
--g-tabs-item-border-widthTabs item border width
--g-tabs-item-gapDistance between tabs
--g-tabs-vertical-item-heightTabs vertical item height
--g-tabs-vertical-item-paddingTabs vertical item padding