Skip to main content

Tab Bar

A segmented-control style tab bar with an animated sliding indicator. Fully controlled via value and onChange, and driven by a tabs array of { value, label } pairs. Tabs split the available width equally unless scrollable is set, so give it a container with real width to fill: a flex parent, or an explicit w.

Playground​

Day
Week
Month
<TabBar
variant="pills"
tabs={tabs}
value={value}
onChange={setValue}
/>

Basic usage​

Day
Week
Month
function TabBarDemo() {
const [value, setValue] = useState('day');

return (
<TabBar
tabs={[
{ value: 'day', label: 'Day' },
{ value: 'week', label: 'Week' },
{ value: 'month', label: 'Month' },
]}
value={value}
onChange={setValue}
/>
);
}

Scrollable​

With scrollable, tabs render at their natural width in a horizontal scroll view instead of splitting the container equally; better once you have more tabs than comfortably fit.

All
Active
Completed
Archived
<TabBar
tabs={[
{ value: 'all', label: 'All' },
{ value: 'active', label: 'Active' },
{ value: 'completed', label: 'Completed' },
{ value: 'archived', label: 'Archived' },
]}
value={value}
onChange={setValue}
scrollable
/>

Props​

PropTypeDefaultDescription
tabs{ value: string; label: string }[]Required. Tabs to render.
valuestringRequired. Value of the active tab.
onChange(value: string) => voidRequired. Called when a tab is pressed.
variant'pills' | 'segmented' | 'underline''pills'Indicator style. pills/segmented fill a pill behind the active tab; underline draws a thin line beneath it instead.
trackBgTVajraColorsResolved per variantBackground color of the outer track.
trackRoundedTRoundedTokenResolved per variantCorner radius of the outer track.
trackPaddingTSpacingToken's-1'Padding around tabs inside the track.
indicatorBgTVajraColorsResolved per variantBackground color of the sliding active indicator.
indicatorRoundedTRoundedTokenResolved per variantCorner radius of the sliding indicator.
underlineHeightnumber2Thickness (px) of the underline indicator, when variant="underline".
activeColorTVajraColors'text'Label color for the active tab.
inactiveColorTVajraColors'textMuted'Label color for inactive tabs.
labelPropsOmit<TTextProps, 'color'>Extra props passed to each tab's Text label.
scrollablebooleanfalseRenders tabs in a horizontal ScrollView with natural width instead of equal-width flex.