Introducing PrimeReact v11-alpha 🎉Discover Now

Toolbar

An unstyled toolbar component with compound composition for grouping actions.

Build fully custom toolbar layouts with complete control over content regions and styling.

basic-demo

Pre-styled Versions

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

Features#

  • Compound component API with four sub-components: Root, Start, Center, End
  • Three-region layout for start, center, and end content alignment
  • Context sharing from Root to all descendant sub-components

Usage#

import { Toolbar } from 'primereact/toolbar';
<Toolbar.Root>
    <Toolbar.Start />
    <Toolbar.Center />
    <Toolbar.End />
</Toolbar.Root>

Behavior#

Polymorphic Rendering#

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

<Toolbar.Root as="nav">
    <Toolbar.Start as="ul">...</Toolbar.Start>
</Toolbar.Root>

Default elements: Root=div, Start=div, Center=div, End=div.

Render Function Children#

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

<Toolbar.Start>{(instance) => <span>Toolbar ID: {instance.toolbar?.id}</span>}</Toolbar.Start>

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#

ToolbarRoot#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: ToolbarRootInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: ToolbarRootInstance) => 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.
instanceToolbarRootInstance—
The instance to pass to the component.
ptSafeRecord<ToolbarRootPassThrough>—
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: ToolbarRootInstance) => 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.
AttributeValue
data-scopetoolbar
data-partroot

Defines passthrough(pt) options of Toolbar component.

labeltypedescription
rootToolbarRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.
startToolbarRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the start's DOM element.
centerToolbarRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the center's DOM element.
endToolbarRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the end's DOM element.

ToolbarStart#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: ToolbarStartInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: ToolbarStartInstance) => 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.
instanceToolbarStartInstance—
The instance to pass to the component.
ptSafeRecord<ToolbarStartPassThrough>—
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: ToolbarStartInstance) => 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 ToolbarStart component.

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

ToolbarCenter#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: ToolbarCenterInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: ToolbarCenterInstance) => 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.
instanceToolbarCenterInstance—
The instance to pass to the component.
ptSafeRecord<ToolbarCenterPassThrough>—
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: ToolbarCenterInstance) => 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 ToolbarCenter component.

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

ToolbarEnd#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: ToolbarEndInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: ToolbarEndInstance) => 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.
instanceToolbarEndInstance—
The instance to pass to the component.
ptSafeRecord<ToolbarEndPassThrough>—
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: ToolbarEndInstance) => 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 ToolbarEnd component.

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

Accessibility#

Screen Reader#

Toolbar uses role="toolbar" on the root element. aria-orientation is not included as it defaults to "horizontal". Provide an accessible label via aria-label or aria-labelledby on Root.

Keyboard Support#

Component does not include built-in keyboard interaction. Keyboard behavior depends on interactive elements placed inside the toolbar (buttons, inputs, etc.). Follow the WAI-ARIA Toolbar Pattern for managing focus with arrow keys if needed.