Skip to content

components/Tabs

import { … } from 'zidane-ui'ui/src/components/Tabs.tsx

Components#

TabsComponent#

Renders a tab list over the selected tab's panel.

TypeScript
function Tabs(props: TabsProps): Element
Parameters
NameTypeDescription
propsTabsProps

TabsProps.

Element
Tabs props
NameTypeDefaultDescription
ariaLabel?string

Accessible name of the tab list.

className?string

Extra classes on the root element.

defaultValue?string

The first selected tab. Default: the first item.

itemsreadonly TabsItem[]

The tabs, in order.

listClassName?string

Classes on a box around the tab list (absent: no box). A surface that scrolls under its tabs makes it sticky here (sticky top-0 and its own background), so the list stays in view.

onChange?(id: string) => void

Called with the id of the tab picked by click or keyboard.

size?'sm' | 'md''sm'

Tab height: sm is 24px, md is 28px.

style?CSSProperties

Inline styles on the root element.

value?string

The selected tab's id, controlled. Use it with onChange.

ui/src/components/Tabs.tsx:54

Interfaces#

TabsItemInterface#

One tab of Tabs.

TypeScript
interface TabsItem
TabsItem properties
NameTypeDescription
contentReactNode

The panel the tab shows.

idstring

Stable id, unique among the items.

labelReactNode

The tab's label.

ui/src/components/Tabs.tsx:12

TabsPropsInterface#

Props for Tabs.

TypeScript
interface TabsProps
TabsProps properties
NameTypeDefaultDescription
ariaLabel?string

Accessible name of the tab list.

className?string

Extra classes on the root element.

defaultValue?string

The first selected tab. Default: the first item.

itemsreadonly TabsItem[]

The tabs, in order.

listClassName?string

Classes on a box around the tab list (absent: no box). A surface that scrolls under its tabs makes it sticky here (sticky top-0 and its own background), so the list stays in view.

onChange?(id: string) => void

Called with the id of the tab picked by click or keyboard.

size?'sm' | 'md''sm'

Tab height: sm is 24px, md is 28px.

style?CSSProperties

Inline styles on the root element.

value?string

The selected tab's id, controlled. Use it with onChange.

ui/src/components/Tabs.tsx:22