DocsBlog
  • 0.25.3

  • light

    dark

    system

    Switch mode
  • Cerberus

    Acheron

    Elysium

Get Started
Components
Styling
Theming

Concepts

OverviewCompositionTesting

Layout

Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridLink OverlayScrollableStackWrap

Components

AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMenuNotificationsNumber InputPin InputProgressPrompt ModalRadioRatingSelectSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

Utilities

Client OnlyDownload TriggerEnvironmentFeature FlagsFocus TrapForFormat ByteFormat NumberFormat Relative TimeFrameHighlightJSON Tree ViewLocaleLocal StoragePortalPresenceShowsplitPropsTheme

Tabs

The Tabs component is used to create a tabbed interface.

  • npm
  • source
  • recipe
  • Ark
import { Tabs } from '@cerberus/react'

Usage

The Tabs component is used to create a tabbed interface.

Overview content
Features content
Pricing content
Copy
Basic demo
import { Tabs } from '@cerberus/react'
import { Box } from 'styled-system/jsx'
export function BasicTabsPreview() {
return (
<Box w="1/2">
<Tabs.Root defaultValue="overview">
<Tabs.List>
<Tabs.Tab value="overview">Overview</Tabs.Tab>
<Tabs.Tab value="features">Features</Tabs.Tab>
<Tabs.Tab value="pricing">Pricing</Tabs.Tab>
</Tabs.List>
<Tabs.Panel value="overview">Overview content</Tabs.Panel>
<Tabs.Panel value="features">Features content</Tabs.Panel>
<Tabs.Panel value="pricing">Pricing content</Tabs.Panel>
</Tabs.Root>
</Box>
)
}

Palette

The palette prop can be used to change the color of the Tabs.

Overview content
Features content
Pricing content
Copy
tabs.tsx
function SecondaryTabsPreview() {
return (
<Box w="1/2">
<Tabs.Root defaultValue="overview-1" palette="secondaryAction">
<Tabs.List>
<Tabs.Tab value="overview-1">Overview</Tabs.Tab>
<Tabs.Tab value="features-1">Features</Tabs.Tab>
<Tabs.Tab value="pricing-1">Pricing</Tabs.Tab>
</Tabs.List>
<Tabs.Panel value="overview-1">Overview content</Tabs.Panel>
<Tabs.Panel value="features-1">Features content</Tabs.Panel>
<Tabs.Panel value="pricing-1">Pricing content</Tabs.Panel>
</Tabs.Root>
</Box>
)
}

Primitives

You can utilize the primitive components or the css prop to customize the tabs.

ComponentDescription
TabsRootThe context provider for the tabs parts
TabsListThe list container of the tabs
TabsTriggerThe tab components of the tabs
TabsIndicatorThe indicator of the active tabs state
TabsContentThe panel container for the tabs.
A peaceful and quiet region of the underworld.
A paradise for the souls of the heroic and the virtuous.
A deep abyss used as a dungeon of torment and suffering.
Copy
Custom tabs demo
import { Tabs, For } from '@cerberus/react'
import { Box } from 'styled-system/jsx'
function CustomTabsPreview() {
const tabData = [
{
id: 'asphodel',
label: 'Asphodel',
content: 'A peaceful and quiet region of the underworld.',
},
{
id: 'elysium',
label: 'Elysium',
content: 'A paradise for the souls of the heroic and the virtuous.',
},
{
id: 'tartarus',
label: 'Tartarus',
content: 'A deep abyss used as a dungeon of torment and suffering.',
},
]
return (
<Box w="1/2">
<Tabs.Root defaultValue="asphodel">
<Tabs.List
css={{
bgColor: 'page.surface.200',
borderBottom: 'none',
rounded: 'md',
'& > :is([data-part=indicator])': {
bgColor: 'danger.surface.initial',
h: 'var(--height)',
rounded: 'md',
zIndex: 'base',
},
}}
>
{tabData.map((tab) => (
<Tabs.Tab
css={{
zIndex: 'decorator',
_selected: {
color: 'danger.text.100',
},
_after: {
display: 'none',
},
}}
key={tab.id}
value={tab.value}
>
{tab.label}
</Tabs.Tab>
))}
</Tabs.List>
<For each={tabData}>
{(tab) => (
<Tabs.Panel
key={tab.id}
value={tab.value}
css={{
paddingBlock: 'md',
}}
>
{tab.content}
</Tabs.Panel>
)}
</For>
</Tabs.Root>
</Box>
)
}

API

Props

The Tabs component is an abstraction of the primitives and accepts the following props:

NameDefaultDescription
paletteactionThe color palette of the tabs

The Tabs.Root component also accepts all the props of the TabsRoot primitive props

Tabs component parts

The Tabs API is an Object containing the full family of abstracted components.

Note

Although the Tabs API is similar to the TabsParts, it returns abstractions of the primitives. The TabsParts return the primitives only.

NameDescription
RootAn abstraction of the TabsRoot.
ListAn abstraction of the TabsList and TabsIndicator.
TabAn abstraction of the TabsTrigger.
PanelAn abstraction of the TabsContent.

Parts

The TabsParts API is an Object containing the full family of components.

Note

It is best to only use the TabsParts if you are building a custom solution. Importing Object based components will ship every property it includes into your bundle, regardless if you use it or not.

NameDescription
RootThe TabsRoot component which is the Provider for the family.
ListThe TabsList component which is the container for the tabs.
TriggerThe TabsTrigger component which is the tab component.
ContentThe TabsContent component which is the panel container.
IndicatorThe TabsIndicator component which displays based on the active state.

On this page

  • Edit this page on Github
Cerberus Design System | Docs