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.

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.
trackBgTVajraColors'surfaceRaised'Background color of the outer track.
trackRoundedTRoundedToken'r-full'Corner radius of the outer track.
trackPaddingTSpacingToken's-1'Padding around tabs inside the track.
indicatorBgTVajraColors'surface'Background color of the sliding active indicator.
indicatorRoundedTRoundedToken'r-full'Corner radius of the sliding indicator.
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.