Skip to main content
The Toolbar component provides a container for organizing related action buttons, inputs, and controls in a horizontal layout. It’s built on top of Base UI’s Toolbar component and includes visual separators and grouping capabilities.

Installation

npx shadcn@latest add @eo-n/toolbar

Usage

Import the toolbar components and compose them together:
import {
  Toolbar,
  ToolbarButton,
  ToolbarGroup,
  ToolbarSeparator,
  ToolbarLink,
  ToolbarInput,
} from "@/components/ui/toolbar";
<Toolbar>
  <ToolbarButton render={<Button>Save</Button>} />
  <ToolbarSeparator />
  <ToolbarGroup>
    <ToolbarButton render={<Button variant="outline">Undo</Button>} />
    <ToolbarButton render={<Button variant="outline">Redo</Button>} />
  </ToolbarGroup>
</Toolbar>

Components

Toolbar

The root container component that wraps all toolbar items. Props: Extends React.ComponentProps<typeof ToolbarPrimitive.Root>

ToolbarButton

A wrapper for rendering buttons within the toolbar with consistent styling. Props: Extends React.ComponentProps<typeof ToolbarPrimitive.Button>
  • render - A React element to render inside the button wrapper
A link element styled for use within the toolbar. Props: Extends React.ComponentProps<typeof ToolbarPrimitive.Link>
  • href - The URL the link points to

ToolbarInput

A wrapper for rendering input fields within the toolbar. Props: Extends React.ComponentProps<typeof ToolbarPrimitive.Input>
  • render - A React element to render inside the input wrapper

ToolbarGroup

Groups related toolbar items together visually. Props: Extends React.ComponentProps<typeof ToolbarPrimitive.Group>

ToolbarSeparator

A visual separator between toolbar items or groups. Props: Extends React.ComponentProps<typeof ToolbarPrimitive.Separator>

Examples

Basic Toolbar

import { Bold, Italic, Undo2, Redo2 } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Toggle } from "@/components/ui/toggle";
import {
  Toolbar,
  ToolbarButton,
  ToolbarGroup,
  ToolbarSeparator,
} from "@/components/ui/toolbar";

export default function ToolbarDemo() {
  return (
    <Toolbar>
      <ToolbarButton render={<Button variant="default">Save</Button>} />
      <ToolbarSeparator />
      <ToolbarGroup>
        <ToolbarButton
          render={
            <Button variant="outline">
              <Undo2 />
              Undo
            </Button>
          }
        />
        <ToolbarButton
          render={
            <Button variant="outline">
              <Redo2 />
              Redo
            </Button>
          }
        />
      </ToolbarGroup>
      <ToolbarSeparator />
      <ToolbarGroup>
        <ToolbarButton
          render={
            <Toggle variant="outline">
              <Bold />
            </Toggle>
          }
        />
        <ToolbarButton
          render={
            <Toggle variant="outline">
              <Italic />
            </Toggle>
          }
        />
      </ToolbarGroup>
    </Toolbar>
  );
}

Toolbar with Input

Combine toolbar buttons with input fields:
import { Bold, Italic } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Toggle } from "@/components/ui/toggle";
import {
  Toolbar,
  ToolbarButton,
  ToolbarGroup,
  ToolbarInput,
  ToolbarSeparator,
} from "@/components/ui/toolbar";

export default function ToolbarWithInput() {
  return (
    <Toolbar>
      <ToolbarButton render={<Button variant="default">Save</Button>} />
      <ToolbarSeparator />
      <ToolbarGroup>
        <ToolbarButton
          render={
            <Toggle variant="outline">
              <Bold />
            </Toggle>
          }
        />
        <ToolbarButton
          render={
            <Toggle variant="outline">
              <Italic />
            </Toggle>
          }
        />
      </ToolbarGroup>
      <ToolbarSeparator />
      <ToolbarInput render={<Input placeholder="Search and replace" />} />
    </Toolbar>
  );
}
Include links for help or documentation:
import { HelpCircle } from "lucide-react";
import {
  Toolbar,
  ToolbarButton,
  ToolbarLink,
  ToolbarSeparator,
} from "@/components/ui/toolbar";

export default function ToolbarWithLink() {
  return (
    <Toolbar>
      <ToolbarButton render={<Button>Save</Button>} />
      <ToolbarSeparator />
      <ToolbarLink href="#">
        <HelpCircle />
        Learn More
      </ToolbarLink>
    </Toolbar>
  );
}

Accessibility

  • The toolbar follows WAI-ARIA toolbar pattern
  • Keyboard navigation is supported with arrow keys
  • Focus management is handled automatically
  • Use appropriate aria-label attributes on icon-only buttons

API Reference

For more information about the Base UI Toolbar component, see the Base UI documentation.

Build docs developers (and LLMs) love