Tabs
Controlled tab list with keyboard navigation and an active indicator.
Demo
Usage
import { useState } from 'react'
import { Tabs } from 'regen-ui'
const tabs = [
{ id: 'overview', label: 'Overview' },
{ id: 'activity', label: 'Activity' },
{ id: 'settings', label: 'Settings' },
] as const
export function SectionTabs() {
const [active, setActive] = useState<(typeof tabs)[number]['id']>('overview')
return <Tabs active={active} aria-label="Sections" onChange={setActive} tabs={tabs} />
}Expanded Usage
import { useState } from 'react'
import { Tabs } from 'regen-ui'
const tabs = [
{ id: 'overview', label: 'Overview' },
{ id: 'activity', label: 'Activity' },
{ id: 'settings', label: 'Settings' },
] as const
export function SectionTabs() {
const [active, setActive] = useState<(typeof tabs)[number]['id']>('overview')
return <Tabs active={active} aria-label="Sections" expand onChange={setActive} tabs={tabs} />
}API Reference
Tabs.Props<T extends string>
| Name | Type | Default | Description |
|---|---|---|---|
active | T | None | Currently selected tab id. |
expand | boolean | false | Expand tabs equally across the tab list. |
onChange | (id: T) => void | None | Called when the selected tab should change. |
tabs | readonly Item<T>[] | None | Tabs rendered in order. |
Inherits HTMLAttributes<HTMLDivElement>, except onChange. | |||
activeType
TDefaultNone
Currently selected tab id.expandType
booleanDefault
Expand tabs equally across the tab list.falseonChangeType
(id: T) => voidDefaultNone
Called when the selected tab should change.tabsType
readonly Item<T>[]DefaultNone
Tabs rendered in order.Inherits
HTMLAttributes<HTMLDivElement>, except onChange.Tabs.Item<T extends string>
| Name | Type | Default | Description |
|---|---|---|---|
icon | ReactNode | None | Optional icon rendered before the label. |
id | T | None | Stable tab id passed to `active` and `onChange`. |
label | ReactNode | None | Visible tab label. |
iconType
ReactNodeDefaultNone
Optional icon rendered before the label.idType
TDefaultNone
Stable tab id passed to `active` and `onChange`.labelType
ReactNodeDefaultNone
Visible tab label.