Skip to main content

Tabs

Switch between panels of related content in the same place, built on Base UI's Tabs primitive. Click a tab or use the arrow keys to move between tabs.

import { Tabs } from '@jbpark/ui-kit';

<Tabs
items={[
{ key: 'overview', label: 'Overview', children: <p>Overview</p> },
{ key: 'activity', label: 'Activity', children: <p>Activity</p> },
{ key: 'settings', label: 'Settings', children: null, disabled: true },
]}
/>;

A summary of the project.

Props​

PropTypeDefaultDescription
itemsItem[]requiredTabs and their panels.
valuestring | number | null-Controlled selected key.
defaultValuestring | number | nullfirst enabled itemInitial selected key when uncontrolled.
onChange(value: string | number | null) => void-Called when the selected tab changes.
orientation'horizontal' | 'vertical''horizontal'Layout direction of the tab list.
activateOnFocusbooleanfalseSelect a tab as soon as arrow-key focus moves to it.
keepMountedbooleanfalseKeep inactive panels in the DOM, preserving their local state.
scrollablebooleanfalseScroll the tab list when the tabs do not fit.
fittedbooleanfalseGive tabs equal width in horizontal mode. Ignored when scrollable.
extraReactNode-Content shown after the tab list, outside the tablist role.
listLabelstring'Tabs'Accessible name of the tab list.
classNamestring-Root class.
classNames{ list?, tab?, panel?, extra? }-Classes for internal parts.

Each Item has a required key, label, and children (the panel content), and optional disabled and icon. The icon is decorative and is rendered before the label.

onValueChange (Base UI's signature, with event details) still works but is deprecated. Use onChange.