moduix

Toolbar

A container for grouping buttons, toggles, links, inputs, and popup triggers.

API Reference

Original primitive API

Behavior, accessibility details, and low-level props are documented by Base UI.

Base UI API

Basic

import {  BellIcon,  Toolbar,  ToolbarButton,  ToolbarGroup,  ToolbarInput,  ToolbarLink,  ToolbarSeparator,} from "moduix";export function ToolbarDemo() {  return (    <Toolbar aria-label="Document actions">      <ToolbarGroup aria-label="History">        <ToolbarButton>Undo</ToolbarButton>        <ToolbarButton>Redo</ToolbarButton>      </ToolbarGroup>      <ToolbarSeparator />      <ToolbarInput aria-label="Search actions" placeholder="Search actions" />      <ToolbarButton aria-label="Notifications">        <BellIcon />      </ToolbarButton>      <ToolbarLink href="#">History</ToolbarLink>    </Toolbar>  );}

Full list of component variables available for project-level overrides.

PropertyDefaultDescription
--toolbar-bgvar(--color-muted)Controls toolbar background color.
--toolbar-border-colorvar(--color-border)Controls toolbar border color.
--toolbar-border-widthvar(--border-width-sm)Controls toolbar border width.
--toolbar-colorvar(--color-foreground)Controls toolbar text color.
--toolbar-control-bg-activevar(--color-accent)Controls button active background.
--toolbar-control-bg-hovervar(--color-accent)Controls button hover background.
--toolbar-control-bg-pressedvar(--color-background)Controls pressed and open button background.
--toolbar-control-border-color-activetransparentControls active control border color.
--toolbar-control-border-widthvar(--border-width-sm)Controls toolbar button border width.
--toolbar-control-colorvar(--color-foreground)Controls button text color.
--toolbar-control-color-pressedvar(--color-foreground)Controls pressed and open button text color.
--toolbar-control-gapvar(--spacing-2)Controls spacing inside toolbar buttons.
--toolbar-control-heightvar(--size-lg)Controls base control height.
--toolbar-control-height-smvar(--size-sm)Controls small control height.
--toolbar-control-height-lgvar(--size-xl)Controls large control height.
--toolbar-control-padding-x-lg1remControls large control horizontal padding.
--toolbar-control-padding-x-sm0.625remControls small control horizontal padding.
--toolbar-control-padding-x0.75remControls control horizontal padding.
--toolbar-control-radiusvar(--radius-md)Controls control corner radius.
--toolbar-disabled-opacityvar(--opacity-disabled)Controls disabled control opacity.
--toolbar-focus-ring-colorvar(--color-ring)Controls keyboard focus ring color.
--toolbar-focus-ring-offset-1pxControls keyboard focus ring offset.
--toolbar-focus-ring-widthvar(--border-width-md)Controls keyboard focus ring width.
--toolbar-font-size-smvar(--text-xs)Controls small control font size.
--toolbar-font-size-lgvar(--text-md)Controls large control font size.
--toolbar-font-sizevar(--text-sm)Controls base control font size.
--toolbar-font-weightvar(--weight-medium)Controls control font weight.
--toolbar-gapvar(--border-width-sm)Controls spacing between toolbar items.
--toolbar-group-gapvar(--spacing-1)Controls spacing inside toolbar groups.
--toolbar-icon-size-sm0.875remControls small control icon size.
--toolbar-icon-size1remControls control icon size.
--toolbar-input-bgvar(--color-background)Controls input background.
--toolbar-input-border-colorvar(--color-border)Controls input border color.
--toolbar-input-border-widthvar(--border-width-sm)Controls input border width.
--toolbar-input-colorvar(--color-foreground)Controls input text color.
--toolbar-input-focus-ring-offset-1pxControls input focus ring offset.
--toolbar-input-focus-ring-widthvar(--border-width-sm)Controls input focus ring width.
--toolbar-input-padding-x0.75remControls input horizontal padding.
--toolbar-input-placeholder-colorvar(--color-muted-foreground)Controls input placeholder color.
--toolbar-input-width-sm8remControls small toolbar input width.
--toolbar-input-width-lg12remControls large toolbar input width.
--toolbar-input-width10remControls input width.
--toolbar-line-height-smvar(--line-height-text-xs)Controls small control line height.
--toolbar-line-height-lgvar(--line-height-text-md)Controls large control line height.
--toolbar-line-heightvar(--line-height-text-sm)Controls base control line height.
--toolbar-padding0.125remControls toolbar inner padding.
--toolbar-radiusvar(--radius-lg)Controls toolbar corner radius.
--toolbar-separator-colorvar(--color-border)Controls separator color.
--toolbar-separator-length-horizontal100%Controls horizontal separator length.
--toolbar-separator-length-vertical1remControls vertical separator length.
--toolbar-separator-margin-x-verticalvar(--spacing-1)Controls vertical separator horizontal margin.
--toolbar-separator-margin-y-horizontalvar(--spacing-1)Controls horizontal separator vertical margin.
--toolbar-separator-thickness1pxControls separator thickness.
--toolbar-separator-thickness-horizontalvar(--toolbar-separator-thickness)Controls horizontal separator thickness.
--toolbar-separator-thickness-verticalvar(--toolbar-separator-thickness)Controls vertical separator thickness.
--toolbar-transitionvar(--transition-default)Controls interactive transition timing.

Interactive variables scoped for docs preview without changing size scale tokens.

PropertyValueDefaultDescription
--toolbar-bgvar(--color-muted)Controls toolbar background color.
--toolbar-border-colorvar(--color-border)Controls toolbar border color.
--toolbar-colorvar(--color-foreground)Controls toolbar text color.
--toolbar-control-bg-activevar(--color-accent)Controls button active background.
--toolbar-control-bg-hovervar(--color-accent)Controls button hover background.
--toolbar-control-colorvar(--color-foreground)Controls button text color.
--toolbar-input-bgvar(--color-background)Controls input background.
--toolbar-input-border-colorvar(--color-border)Controls input border color.
--toolbar-radiusvar(--radius-lg)Controls toolbar corner radius.
--toolbar-separator-colorvar(--color-border)Controls separator color.

Anatomy

Toolbar groups related controls into one keyboard navigation region. Use visible parts for actions, grouped actions, separators, inputs, and links.

Toolbar[aria-label]
├─ ToolbarGroup[aria-label]
│  └─ ToolbarButton
├─ ToolbarSeparator
├─ ToolbarInput
├─ ToolbarButton
└─ ToolbarLink
<Toolbar aria-label="Document actions">
  <ToolbarGroup aria-label="History">
    <ToolbarButton>Undo</ToolbarButton>
    <ToolbarButton>Redo</ToolbarButton>
  </ToolbarGroup>
  <ToolbarSeparator />
  <ToolbarInput aria-label="Search actions" placeholder="Search actions" />
  <ToolbarButton aria-label="Notifications">
    <BellIcon />
  </ToolbarButton>
  <ToolbarLink href="#">History</ToolbarLink>
</Toolbar>
PartRole
ToolbarRoot toolbar region. Controls orientation, disabled state, visual variant, and control size.
ToolbarGroupGroups related controls inside the toolbar and gives them a shared label when needed.
ToolbarButtonToolbar-aware button. Compose it with Toggle, SelectTrigger, or another trigger via render.
ToolbarInputNative input that participates in toolbar keyboard navigation.
ToolbarLinkToolbar-aware anchor for related navigation or metadata links.
ToolbarSeparatorVisual separator. By default it uses the opposite orientation of the root toolbar.

Toolbar does not use portal-like service layers such as portal, positioner, backdrop, or viewport. All exported parts are visible composition slots, so style the root and parts directly with className or scoped CSS variables.

Composition

Use Toolbar for shared behavior and layout props: aria-label, orientation, disabled, variant, and size. Use ToolbarGroup when a subset of controls needs its own accessible name, and use ToolbarSeparator to divide unrelated groups.

ToolbarButton supports the Base UI render prop. This lets one element act as both a toolbar item and another interactive primitive, such as a Toggle or SelectTrigger, without nesting interactive elements.

<Toolbar aria-label="Text properties">
  <Select defaultValue="Inter">
    <ToolbarButton render={<SelectTrigger />} aria-label="Font family">
      <SelectValue />
      <SelectIcon>
        <ChevronUpDownIcon />
      </SelectIcon>
    </ToolbarButton>
    <SelectContent>
      <SelectList>
        {fonts.map((font) => (
          <SelectItem key={font} value={font}>
            <SelectItemIndicator />
            <SelectItemText>{font}</SelectItemText>
          </SelectItem>
        ))}
      </SelectList>
    </SelectContent>
  </Select>
</Toolbar>

Popup primitives rendered from toolbar buttons, such as SelectContent, own their internal portal and positioner behavior. Configure those slots on that popup component, not on Toolbar.

Examples

Toggle Group

Compose ToolbarButton with Toggle inside a ToggleGroup when toolbar items need pressed state.

import {  BellIcon,  StarIcon,  Toggle,  ToggleGroup,  Toolbar,  ToolbarButton,  ToolbarGroup,  ToolbarSeparator,} from "moduix";export function ToolbarToggleGroupDemo() {  return (    <Toolbar aria-label="Editor formatting">      <ToggleGroup multiple defaultValue={["bold"]} aria-label="Text formatting" variant="ghost">        <ToolbarButton render={<Toggle />} value="bold" aria-label="Bold">          <strong>B</strong>        </ToolbarButton>        <ToolbarButton render={<Toggle />} value="italic" aria-label="Italic">          <em>I</em>        </ToolbarButton>        <ToolbarButton render={<Toggle />} value="underline" aria-label="Underline">          <u>U</u>        </ToolbarButton>      </ToggleGroup>      <ToolbarSeparator />      <ToolbarGroup aria-label="Insert">        <ToolbarButton aria-label="Add favorite">          <StarIcon />        </ToolbarButton>        <ToolbarButton aria-label="Notifications">          <BellIcon />        </ToolbarButton>      </ToolbarGroup>    </Toolbar>  );}

Select And Input

Use the render prop to turn toolbar buttons into popup triggers, and keep inputs limited in horizontal toolbars.

import {  ChevronUpDownIcon,  Select,  SelectContent,  SelectIcon,  SelectItem,  SelectItemIndicator,  SelectItemText,  SelectList,  SelectTrigger,  SelectValue,  Toolbar,  ToolbarButton,  ToolbarInput,  ToolbarLink,  ToolbarSeparator,} from "moduix";export function ToolbarSelectInputDemo() {  return (    <Toolbar aria-label="Text properties">      <Select defaultValue="Inter">        <ToolbarButton render={<SelectTrigger />} aria-label="Font family">          <SelectValue />          <SelectIcon>            <ChevronUpDownIcon />          </SelectIcon>        </ToolbarButton>        <SelectContent>          <SelectList>            {fonts.map((font) => (              <SelectItem key={font} value={font}>                <SelectItemIndicator />                <SelectItemText>{font}</SelectItemText>              </SelectItem>            ))}          </SelectList>        </SelectContent>      </Select>      <ToolbarSeparator />      <ToolbarInput aria-label="Search actions" placeholder="Search actions" />      <ToolbarLink href="#">History</ToolbarLink>    </Toolbar>  );}
const fonts = ["Inter", "Arial", "Helvetica", "Georgia"];

Variants

Use variant to match the toolbar surface to the surrounding layout.

import { BellIcon, Toolbar, ToolbarButton, ToolbarSeparator } from "moduix";export function ToolbarVariantsDemo() {  return (    <>      <Toolbar aria-label="Default toolbar">        <ToolbarButton>Undo</ToolbarButton>        <ToolbarButton>Redo</ToolbarButton>        <ToolbarSeparator />        <ToolbarButton aria-label="Notifications">          <BellIcon />        </ToolbarButton>      </Toolbar>      <Toolbar aria-label="Outline toolbar" variant="outline">        <ToolbarButton>Undo</ToolbarButton>        <ToolbarButton>Redo</ToolbarButton>        <ToolbarSeparator />        <ToolbarButton aria-label="Notifications">          <BellIcon />        </ToolbarButton>      </Toolbar>      <Toolbar aria-label="Ghost toolbar" variant="ghost">        <ToolbarButton>Undo</ToolbarButton>        <ToolbarButton>Redo</ToolbarButton>        <ToolbarSeparator />        <ToolbarButton aria-label="Notifications">          <BellIcon />        </ToolbarButton>      </Toolbar>    </>  );}

Sizes

Use size to align toolbar controls with compact or roomy interfaces.

import { BellIcon, Toolbar, ToolbarButton, ToolbarSeparator } from "moduix";export function ToolbarSizesDemo() {  return (    <>      <Toolbar aria-label="Small toolbar" size="sm">        <ToolbarButton>Undo</ToolbarButton>        <ToolbarButton>Redo</ToolbarButton>        <ToolbarSeparator />        <ToolbarButton aria-label="Notifications">          <BellIcon />        </ToolbarButton>      </Toolbar>      <Toolbar aria-label="Medium toolbar" size="md">        <ToolbarButton>Undo</ToolbarButton>        <ToolbarButton>Redo</ToolbarButton>        <ToolbarSeparator />        <ToolbarButton aria-label="Notifications">          <BellIcon />        </ToolbarButton>      </Toolbar>      <Toolbar aria-label="Large toolbar" size="lg">        <ToolbarButton>Undo</ToolbarButton>        <ToolbarButton>Redo</ToolbarButton>        <ToolbarSeparator />        <ToolbarButton aria-label="Notifications">          <BellIcon />        </ToolbarButton>      </Toolbar>    </>  );}

Vertical

Set orientation="vertical" for toolbars that stack controls in a column.

import { StarIcon, Toolbar, ToolbarButton, ToolbarSeparator } from "moduix";export function ToolbarVerticalDemo() {  return (    <Toolbar orientation="vertical" aria-label="Vertical tools">      <ToolbarButton>Move</ToolbarButton>      <ToolbarButton>Scale</ToolbarButton>      <ToolbarSeparator />      <ToolbarButton aria-label="Favorite">        <StarIcon />      </ToolbarButton>    </Toolbar>  );}

Disabled Controls

Disable individual toolbar controls when an action is visible but unavailable.

import {  BellIcon,  Toolbar,  ToolbarButton,  ToolbarInput,  ToolbarSeparator,} from "moduix";export function ToolbarDisabledControlsDemo() {  return (    <Toolbar aria-label="Disabled document actions">      <ToolbarButton>Undo</ToolbarButton>      <ToolbarButton disabled>Redo</ToolbarButton>      <ToolbarSeparator />      <ToolbarInput aria-label="Search disabled actions" placeholder="Search actions" disabled />      <ToolbarButton aria-label="Notifications" disabled>        <BellIcon />      </ToolbarButton>    </Toolbar>  );}

Custom Icons

Pass icons as children. Icon-only buttons must include an accessible label.

import { Toolbar, ToolbarButton } from "moduix";export function ToolbarCustomIconsDemo() {  return (    <Toolbar aria-label="Text alignment">      <ToolbarButton aria-label="Align left">        <AlignLeftIcon />      </ToolbarButton>      <ToolbarButton aria-label="Align center">        <AlignCenterIcon />      </ToolbarButton>      <ToolbarButton aria-label="Align right">        <AlignRightIcon />      </ToolbarButton>    </Toolbar>  );}function AlignLeftIcon() {  return (    <svg viewBox="0 0 16 16" fill="none" aria-hidden="true" focusable="false">      <path        d="M2.5 3.5h11M2.5 8h8M2.5 12.5h11"        stroke="currentColor"        strokeWidth="1.5"        strokeLinecap="round"      />    </svg>  );}function AlignCenterIcon() {  return (    <svg viewBox="0 0 16 16" fill="none" aria-hidden="true" focusable="false">      <path        d="M2.5 3.5h11M4 8h8M2.5 12.5h11"        stroke="currentColor"        strokeWidth="1.5"        strokeLinecap="round"      />    </svg>  );}function AlignRightIcon() {  return (    <svg viewBox="0 0 16 16" fill="none" aria-hidden="true" focusable="false">      <path        d="M2.5 3.5h11M5.5 8h8M2.5 12.5h11"        stroke="currentColor"        strokeWidth="1.5"        strokeLinecap="round"      />    </svg>  );}

Class Names

Pass className to the root and each part when styling with CSS Modules, Tailwind CSS, or CSS-in-JS.

import {  Toolbar,  ToolbarButton,  ToolbarInput,  ToolbarSeparator,} from "moduix";export function ToolbarClassNamesDemo() {  return (    <Toolbar aria-label="Schedule controls" className={styles.customToolbar}>      <ToolbarButton className={styles.customButton}>Day</ToolbarButton>      <ToolbarButton className={styles.customButton}>Week</ToolbarButton>      <ToolbarSeparator />      <ToolbarInput        aria-label="Filter schedule"        placeholder="Filter"        className={styles.customInput}      />    </Toolbar>  );}
.customToolbar {  --toolbar-bg: color-mix(in oklab, var(--color-primary) 7%, transparent);  --toolbar-border-color: color-mix(in oklab, var(--color-primary) 36%, var(--color-border));  --toolbar-gap: var(--spacing-1);  --toolbar-padding: var(--spacing-1);  --toolbar-radius: var(--radius-md);  --toolbar-control-bg-hover: color-mix(in oklab, var(--color-primary) 14%, transparent);  --toolbar-control-bg-pressed: var(--color-primary);  --toolbar-control-color-pressed: var(--color-primary-foreground);  --toolbar-separator-color: color-mix(in oklab, var(--color-primary) 42%, var(--color-border));}.customButton {  --toolbar-control-radius: var(--radius-sm);  --toolbar-control-padding-x: var(--spacing-3);}.customInput {  --toolbar-input-width: 8rem;}

On this page