Toolbar

A container for grouping a set of buttons and controls.

Base UI React 1.8.0
FineSoft Stencil
Align LeftAlign RightHelveticaEdited 51m ago

Stencil implementation

The Stencil toolbar exposes fs-toolbar-root, fs-toolbar-group, fs-toolbar-button, fs-toolbar-link, fs-toolbar-input, and fs-toolbar-separator. Each control keeps its native semantics; the root owns one roving tab stop, orientation, looping and inherited disabled state. Disabled buttons and inputs remain focusable by default; set focusableWhenDisabled={false} to skip them. Links are never disabled by a toolbar.

fs-toolbar-root, fs-toolbar-group, and fs-toolbar-link place their native elements in Shadow DOM and expose ::part(toolbar), ::part(group), and ::part(link), respectively. The Base UI theme is built in; select data-fs-theme="base-ui" on an ancestor for the optional theme; ordinary themed examples need no classes. Customize the container through --fs-toolbar-* variables or the public part. The slotted controls keep their own rendering boundaries and public APIs.

The family uses a mixed boundary: Button stays in Light DOM to preserve native form ownership, submitter identity and asChild composition; Input stays in Light DOM for native labels, validation, datalist and form associations; Separator’s host owns its semantics and layout box. These three parts do not expose new Shadow parts. Their existing native-element/host selectors remain available; host classes are not copied into the three Shadow parts above. The family-level boundary review does not mean every part has a ShadowRoot.

For button composition, use asChild to reuse one child control instead of creating a nested button. The example uses Stencil Toggle / Toggle Group and the migrated Select. Its native combobox trigger registers with the Toolbar’s roving focus directly. Both visible Stencil files are used by the running example: the client entry reuses the same declarative view used for server rendering.

The React-only Menu / Tooltip / NumberField composition snippets below remain reference examples, not evidence that those cross-component integrations have all been ported. React render functions are not custom-element properties. Native input properties, standard form participation and DOM events are available on Toolbar.Input.

The frozen implementation does not enable Home / End toolbar navigation. It also does not repair the tab stop after manually removing the currently focused final item; Stencil retains that behavior rather than silently changing the reference.

Usage guidelines

To ensure that toolbars are accessible and helpful, follow these guidelines:

  • Use inputs sparingly: Left and right arrow keys are used to both move the text insertion cursor in an input, and to navigate among controls in horizontal toolbars. When using an input in a horizontal toolbar, use only one and place it as the last element of the toolbar.

Anatomy

Import the component and assemble its parts:

Anatomy

Examples

Using with Menu

All Base UI popup components that provide a Trigger component can be integrated with a toolbar by passing the trigger to <Toolbar.Button> with the render prop:

Using popups with toolbar

This applies to <AlertDialog>, <Dialog>, <Menu>, <Popover>, and <Select>.

Using with Tooltip

Unlike other popups, the toolbar item should be passed to the render prop of <Tooltip.Trigger>:

Using popups with toolbar

Using with NumberField

To use a NumberField in the toolbar, pass <NumberField.Input> to <Toolbar.Input> using the render prop:

Using NumberField with toolbar

API reference

Root

A container for grouping a set of controls, such as buttons, toggle groups, or menus. Renders a <div> element.

loopFocusbooleantrue
Description

If true, using keyboard navigation will wrap focus to the other end of the toolbar once the end is reached.

Type
Default
true
disabledboolean
Type
orientationToolbar.Root.Orientation'horizontal'
Description

The orientation of the toolbar.

Type
Default
'horizontal'
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-orientation

Indicates the orientation of the toolbar.

data-disabled

Present when the toolbar is disabled.

Attribute
Description
data-orientation

Indicates the orientation of the toolbar.

data-disabled

Present when the toolbar is disabled.

Toolbar.Root.PropsHide

Re-Export of Root props as ToolbarRootProps

Toolbar.Root.StateHide

Toolbar.Root.OrientationHide

Toolbar.Root.ItemMetadataHide

Button

A button that can be used as-is or as a trigger for other components. Renders a <button> element.

focusableWhenDisabledbooleantrue
Description

When true the item remains focusable when disabled.

Type
Default
true
nativeButtonbooleantrue
Description

Whether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).

Type
Default
true
disabledbooleanfalse
Description

When true the item is disabled.

Type
Default
false
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-orientation

Indicates the orientation of the toolbar.

data-disabled

Present when the button is disabled.

data-focusable

Present when the button remains focusable when disabled.

Attribute
Description
data-orientation

Indicates the orientation of the toolbar.

data-disabled

Present when the button is disabled.

data-focusable

Present when the button remains focusable when disabled.

Toolbar.Button.PropsHide

Re-Export of Button props as ToolbarButtonProps

Toolbar.Button.StateHide

A link component. Renders an <a> element.

classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-orientation

Indicates the orientation of the toolbar.

Attribute
Description
data-orientation

Indicates the orientation of the toolbar.

Toolbar.Link.PropsHide

Re-Export of Link props as ToolbarLinkProps

Toolbar.Link.StateHide

Input

A native input element that integrates with Toolbar keyboard navigation. Renders an <input> element.

defaultValueUnion
Type
focusableWhenDisabledbooleantrue
Description

When true the item remains focusable when disabled.

Type
Default
true
disabledbooleanfalse
Description

When true the item is disabled.

Type
Default
false
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-orientation

Indicates the orientation of the toolbar.

data-disabled

Present when the input is disabled.

data-focusable

Present when the input remains focusable when disabled.

Attribute
Description
data-orientation

Indicates the orientation of the toolbar.

data-disabled

Present when the input is disabled.

data-focusable

Present when the input remains focusable when disabled.

Toolbar.Input.PropsHide

Re-Export of Input props as ToolbarInputProps

Toolbar.Input.StateHide

Group

Groups several toolbar items or toggles. Renders a <div> element.

disabledbooleanfalse
Description

When true all toolbar items in the group are disabled.

Type
Default
false
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-orientation

Indicates the orientation of the toolbar.

data-disabled

Present when the group is disabled.

Attribute
Description
data-orientation

Indicates the orientation of the toolbar.

data-disabled

Present when the group is disabled.

Toolbar.Group.PropsHide

Re-Export of Group props as ToolbarGroupProps

Toolbar.Group.StateHide

Separator

A separator element accessible to screen readers. Renders a <div> element.

orientationOrientation
Description

The orientation of the separator. Defaults to the opposite of the toolbar’s orientation, so a horizontal toolbar renders vertical separators.

Type
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-orientation

Indicates the orientation of the separator, which is perpendicular to the toolbar.

Attribute
Description
data-orientation

Indicates the orientation of the separator, which is perpendicular to the toolbar.

Toolbar.Separator.PropsHide

Re-Export of Separator props as ToolbarSeparatorProps

Toolbar.Separator.StateHide