Introducing PrimeReact v11-alpha 🎉Discover Now

Tabs

An unstyled tab component with keyboard navigation and scrollable overflow support.

Build fully custom tabbed interfaces with complete control over layout and styling.

Account Info

Update your personal information such as name, email address, and profile picture.

Payment

Manage your subscription plan, view invoices, and update your payment method.

Preferences

Customize how the application looks and behaves to match your personal preferences.

basic-demo

Pre-styled Versions

Choose a pre-styled library to use Tabs with ready-made designs.
For hook-based usage without components, see the Headless API.

Features#

  • Compound component API with sub-components: Root, List, Content, Tab, Indicator, Panels, Panel, Prev, Next
  • Automatic keyboard focus cycling across tabs with arrow keys, Home, and End
  • Active bar indicator with CSS custom properties for animated positioning
  • Built-in scroll navigation with Prev/Next buttons for overflow tab lists
  • Configurable scroll strategy: nearest, center, disabled, or custom function

Usage#

import { Tabs } from 'primereact/tabs';
<Tabs.Root defaultValue="tab1">
    <Tabs.List>
        <Tabs.Prev></Tabs.Prev>
        <Tabs.Content>
            <Tabs.Tab value="tab1"></Tabs.Tab>
            <Tabs.Indicator />
        </Tabs.Content>
        <Tabs.Next></Tabs.Next>
    </Tabs.List>
    <Tabs.Panels>
        <Tabs.Panel value="tab1"></Tabs.Panel>
    </Tabs.Panels>
</Tabs.Root>

Behavior#

Polymorphic Rendering#

Use as on any sub-component to change the rendered HTML element.

<Tabs.Root as="section">
    <Tabs.List as="nav">...</Tabs.List>
</Tabs.Root>

Render Function Children#

Sub-components accept a render function as children, providing access to the component instance.

<Tabs.Tab value="tab1">{(instance) => <span className={instance.active ? 'active' : ''}>{instance.props.value}</span>}</Tabs.Tab>

Pass Through#

Some parts may not be visible in the preview depending on the component's current state.

Loading...
/* Select a part to see its CSS selector for custom styling */

API#

TabsRoot#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: TabsRootInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: TabsRootInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceTabsRootInstance—
The instance to pass to the component.
ptSafeRecord<TabsRootPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: TabsRootInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
valuestring | numberundefined
Value of the active tab. Use for controlled mode.
defaultValuestring | numberundefined
Default value of the active tab. Use for uncontrolled mode.
selectOnFocusbooleanfalse
When enabled, the focused tab is activated.
scrollStrategyfalse | "center" | "nearest" | ((content: HTMLElement, tab: HTMLElement) => void)'nearest'
Defines how the active tab is scrolled into view when it changes. - `'nearest'` : scrolls only if the tab is clipped or too close to an edge, with padding. - `'center'` : always centers the active tab in the viewport. - `false` : disables auto-scrolling. - `function` : a custom scroll function receiving the content element and active tab element.
tabIndexnumber0
The tabIndex of the active tab.
onValueChange(event: useTabsChangeEvent) => void—
Callback fired when the tabs's value changes.
lazybooleanfalse
When enabled, hidden tabs are not rendered at all. Defaults to false that hides tabs with css.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of Tabs component.

labeltypedescription
rootTabsRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.
listTabsRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the list's DOM element.
contentTabsRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the content's DOM element.
tabTabsRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the tab's DOM element.
indicatorTabsRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the indicator's DOM element.
panelsTabsRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the panels' DOM element.
panelTabsRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the panel's DOM element.
prevTabsRootPassThroughType<HTMLAttributes<HTMLButtonElement>>Used to pass attributes to the prev button's DOM element.
nextTabsRootPassThroughType<HTMLAttributes<HTMLButtonElement>>Used to pass attributes to the next button's DOM element.

TabsList#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: TabsListInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: TabsListInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceTabsListInstance—
The instance to pass to the component.
ptSafeRecord<TabsListPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: TabsListInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of TabsList component.

labeltypedescription
rootTabsListPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

TabsContent#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: TabsContentInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: TabsContentInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceTabsContentInstance—
The instance to pass to the component.
ptSafeRecord<TabsContentPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: TabsContentInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of TabsContent component.

labeltypedescription
rootTabsContentPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

TabsTab#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: TabsTabInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: TabsTabInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceTabsTabInstance—
The instance to pass to the component.
ptSafeRecord<TabsTabPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: TabsTabInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
valuestring | number—
Value of the tab.
disabledbooleanfalse
Whether the tab is disabled.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-activePresent when active
data-disabledPresent when disabled

Defines passthrough(pt) options of TabsTab component.

labeltypedescription
rootTabsTabPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

TabsIndicator#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: TabsIndicatorInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: TabsIndicatorInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceTabsIndicatorInstance—
The instance to pass to the component.
ptSafeRecord<TabsIndicatorPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: TabsIndicatorInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
valuestring | number—
Value of the tabsindicator.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

CSS Custom Properties

The indicator element exposes CSS custom properties for animated positioning relative to the active tab.

CSS VariableDescription
--active-bar-widthWidth of the active tab in pixels
--active-bar-heightHeight of the active tab in pixels
--active-bar-leftLeft offset of the active tab
--active-bar-topTop offset of the active tab

Defines passthrough(pt) options of TabsIndicator component.

labeltypedescription
rootTabsIndicatorPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

TabsPanels#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: TabsPanelsInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: TabsPanelsInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceTabsPanelsInstance—
The instance to pass to the component.
ptSafeRecord<TabsPanelsPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: TabsPanelsInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of TabsPanels component.

labeltypedescription
rootTabsPanelsPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

TabsPanel#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: TabsPanelInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: TabsPanelInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceTabsPanelInstance—
The instance to pass to the component.
ptSafeRecord<TabsPanelPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: TabsPanelInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
valuestring | number—
Value of the tabpanel.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-activePresent when active

Defines passthrough(pt) options of TabsPanel component.

labeltypedescription
rootTabsPanelPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

TabsPrev#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: TabsPrevInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: TabsPrevInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceTabsPrevInstance—
The instance to pass to the component.
ptSafeRecord<TabsPrevPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: TabsPrevInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
ariaLabelstring—
Aria label for the previous button.
lazybooleanfalse
When enabled, the button is unmounted from the DOM when it is not needed.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-disabledPresent when disabled

Defines passthrough(pt) options of TabsPrev component.

labeltypedescription
rootTabsPrevPassThroughType<HTMLAttributes<HTMLButtonElement>>Used to pass attributes to the root's DOM element.

TabsNext#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: TabsNextInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: TabsNextInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceTabsNextInstance—
The instance to pass to the component.
ptSafeRecord<TabsNextPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: TabsNextInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
ariaLabelstring—
Aria label for the next button.
lazybooleanfalse
When enabled, the button is unmounted from the DOM when it is not needed.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-disabledPresent when disabled

Defines passthrough(pt) options of TabsNext component.

labeltypedescription
rootTabsNextPassThroughType<HTMLAttributes<HTMLButtonElement>>Used to pass attributes to the root's DOM element.

Accessibility#

Screen Reader#

Tabs uses role="tablist" on the tab container, role="tab" on each tab trigger, and role="tabpanel" on each panel. Active tabs set aria-selected="true". Panels are linked to their tabs via aria-controls and aria-labelledby. Disabled tabs set aria-disabled="true".

Keyboard Support#

KeyFunction
tabMoves focus into the tab list, then to the panel.
right arrowMoves focus to the next tab.
left arrowMoves focus to the previous tab.
homeMoves focus to the first tab.
endMoves focus to the last tab.
enterActivates the focused tab.
spaceActivates the focused tab.