React Toolbar
A glass React toolbar that groups related controls behind a single tab stop, moved through with the arrow keys.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/toolbar.jsonGlass catches the light.
ToolbarToolbarLinkToolbarGroupToolbarInputToolbarButton- +7 more
- +4 more
Text editor
Tab into the toolbar once, then use the arrow keys (Home and End jump). The disabled Redo stays focusable so it can be discovered. Try the formatting on the paragraph below.
Glass works when it stays readable: a blur strong enough to quiet the backdrop, a rim of light to give it an edge, and text that keeps its contrast whatever passes behind.
import { useState } from "react";
import { Menu, MenuContent, MenuRadioGroup, MenuRadioItem, MenuTrigger } from "@/components/sheenui/menu/menu";
import { Toolbar, ToolbarButton, ToolbarGroup, ToolbarLink, ToolbarSeparator, ToolbarSpacer, ToolbarToggle, ToolbarToggleGroup } from "@/components/sheenui/toolbar/toolbar";
// Package build (after the first npm release, or a packed tarball): import { Menu, MenuContent, MenuRadioGroup, MenuRadioItem, MenuTrigger, Toolbar, ToolbarButton, ToolbarGroup, ToolbarLink, ToolbarSeparator, ToolbarSpacer, ToolbarToggle, ToolbarToggleGroup } from "@sheenui/theme";
import { AlignCenter as AlignCenterIcon, AlignLeft as AlignLeftIcon, AlignRight as AlignRightIcon, Bold as BoldIcon, ChevronDown as ChevronIcon, Italic as ItalicIcon, Link as LinkIcon, Redo2 as RedoIcon, Underline as UnderlineIcon, Undo2 as UndoIcon } from "lucide-react";
// This example also uses menu: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/menu.json
type Block = "paragraph" | "h1";
const blockLabels: Record<Block, string> = { paragraph: "Paragraph", h1: "Heading 1" };
export function Example() {
const [marks, setMarks] = useState<string[]>(["bold"]);
const [align, setAlign] = useState<string[]>(["left"]);
const [block, setBlock] = useState<Block>("paragraph");
return (
<Toolbar aria-label="Formatting">
<ToolbarGroup aria-label="History">
<ToolbarButton tooltip="Undo" shortcut="mod+z"><UndoIcon /></ToolbarButton>
<ToolbarButton tooltip="Redo" shortcut="shift+mod+z" disabled><RedoIcon /></ToolbarButton>
</ToolbarGroup>
<ToolbarSeparator />
<Menu>
<ToolbarButton render={<MenuTrigger />}>{blockLabels[block]} <ChevronIcon /></ToolbarButton>
<MenuContent>
<MenuRadioGroup value={block} onValueChange={setBlock}>
<MenuRadioItem value="paragraph">Paragraph</MenuRadioItem>
<MenuRadioItem value="h1">Heading 1</MenuRadioItem>
</MenuRadioGroup>
</MenuContent>
</Menu>
<ToolbarSeparator />
<ToolbarToggleGroup multiple value={marks} onValueChange={setMarks} aria-label="Text style">
<ToolbarToggle value="bold" tooltip="Bold" shortcut="mod+b"><BoldIcon /></ToolbarToggle>
<ToolbarToggle value="italic" tooltip="Italic" shortcut="mod+i"><ItalicIcon /></ToolbarToggle>
<ToolbarToggle value="underline" tooltip="Underline" shortcut="mod+u"><UnderlineIcon /></ToolbarToggle>
</ToolbarToggleGroup>
<ToolbarSeparator />
{/* Single choice: one accent pill glides between the options; required keeps one pressed. */}
<ToolbarToggleGroup required value={align} onValueChange={setAlign} aria-label="Alignment">
<ToolbarToggle value="left" tooltip="Align left"><AlignLeftIcon /></ToolbarToggle>
<ToolbarToggle value="center" tooltip="Align center"><AlignCenterIcon /></ToolbarToggle>
<ToolbarToggle value="right" tooltip="Align right"><AlignRightIcon /></ToolbarToggle>
</ToolbarToggleGroup>
<ToolbarSeparator />
<ToolbarButton tooltip="Insert link" shortcut="mod+k"><LinkIcon /></ToolbarButton>
<ToolbarSpacer />
<ToolbarLink href={"/history"}>Edited 2m ago</ToolbarLink>
</Toolbar>
);
}Files to copy
7 folders · 9 files · 4 packages
- From
theme/src/ components/toolbar/components/kbd/components/tooltip/hooks/{use-controllable.ts, use-latest.ts, use-media-query.ts, use-preferences.ts}motion/tokens.tslib/{cn.ts, form.ts, popup-motion.ts, warn-once.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/toolbar.jsonRegistry item: toolbar. The styles need the Tailwind v4 glass UI setup.- The examples also use
components/drawer/parts/sheet.tsxcomponents/menu/components/status-icons/lib/{glide-highlight.tsx, popup-a11y.ts}
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/menu.json- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Floating selection toolbar
variant="floating" is a glass pill for selection menus and canvases.
Liquid glass bends the light behind it. Keep the text readable by layering a tinted, near-opaque surface under every label.
import { Toolbar, ToolbarButton, ToolbarSeparator, ToolbarToggle, ToolbarToggleGroup } from "@/components/sheenui/toolbar/toolbar";
// Package build (after the first npm release, or a packed tarball): import { Toolbar, ToolbarButton, ToolbarSeparator, ToolbarToggle, ToolbarToggleGroup } from "@sheenui/theme";
import { Bold as BoldIcon, MessageSquare as CommentIcon, Italic as ItalicIcon, Link as LinkIcon, Sparkles as SparkleIcon } from "lucide-react";
export function Example() {
return (
<Toolbar variant="floating" size="sm" aria-label="Selection">
<ToolbarToggleGroup multiple aria-label="Text style">
<ToolbarToggle value="bold" tooltip="Bold" shortcut="mod+b"><BoldIcon /></ToolbarToggle>
<ToolbarToggle value="italic" tooltip="Italic" shortcut="mod+i"><ItalicIcon /></ToolbarToggle>
</ToolbarToggleGroup>
<ToolbarButton tooltip="Link" shortcut="mod+k"><LinkIcon /></ToolbarButton>
<ToolbarButton tooltip="Comment"><CommentIcon /></ToolbarButton>
<ToolbarSeparator />
<ToolbarButton><SparkleIcon /> Ask AI</ToolbarButton>
</Toolbar>
);
}Vertical tool palette
Up and Down move between tools; the tooltips open to the side.
Select tool
Zoom 100%
import { useState } from "react";
import { Toolbar, ToolbarButton, ToolbarSeparator, ToolbarToggle, ToolbarToggleGroup } from "@/components/sheenui/toolbar/toolbar";
// Package build (after the first npm release, or a packed tarball): import { Toolbar, ToolbarButton, ToolbarSeparator, ToolbarToggle, ToolbarToggleGroup } from "@sheenui/theme";
import { Hand as HandIcon, Minus as MinusIcon, Pen as PenIcon, Plus as PlusIcon, MousePointer2 as PointerIcon, Square as SquareIcon, Type as TypeIcon } from "lucide-react";
export function Example() {
const [tool, setTool] = useState<string[]>(["select"]);
return (
<Toolbar orientation="vertical" aria-label="Tools">
<ToolbarToggleGroup required value={tool} onValueChange={setTool} aria-label="Tool">
<ToolbarToggle value="select" tooltip="Select" shortcut="v"><PointerIcon /></ToolbarToggle>
<ToolbarToggle value="hand" tooltip="Hand" shortcut="h"><HandIcon /></ToolbarToggle>
<ToolbarToggle value="pen" tooltip="Pen" shortcut="p"><PenIcon /></ToolbarToggle>
<ToolbarToggle value="shape" tooltip="Rectangle" shortcut="r"><SquareIcon /></ToolbarToggle>
<ToolbarToggle value="text" tooltip="Text" shortcut="t"><TypeIcon /></ToolbarToggle>
</ToolbarToggleGroup>
<ToolbarSeparator />
<ToolbarButton tooltip="Zoom in" shortcut="mod+="><PlusIcon /></ToolbarButton>
<ToolbarButton tooltip="Zoom out" shortcut="mod+-"><MinusIcon /></ToolbarButton>
</Toolbar>
);
}Narrow screens
overflow="scroll" keeps one row that scrolls sideways inside the toolbar; the default wraps onto more rows. Both stay inside their container at 320px.
import { Toolbar, ToolbarButton, ToolbarInput } from "@/components/sheenui/toolbar/toolbar";
// Package build (after the first npm release, or a packed tarball): import { Toolbar, ToolbarButton, ToolbarInput } from "@sheenui/theme";
export function Example() {
// One row that scrolls sideways on narrow screens, with fades on the edges that have more.
return (
<>
<Toolbar overflow="scroll" aria-label="Formatting">
<ToolbarButton>Bold</ToolbarButton>
<ToolbarButton>Italic</ToolbarButton>
<ToolbarButton>Underline</ToolbarButton>
</Toolbar>
{/* A search field: at most one, and last (arrow keys move its caret). */}
<ToolbarInput aria-label="Search in document" placeholder="Search" />
</>
);
}Toolbar
ToolbarButton / ToolbarToggle
ToolbarToggleGroup
ToolbarGroup, ToolbarSeparator, ToolbarSpacer, ToolbarLink, ToolbarInput
Keyboard
Accessibility
- role="toolbar" with roving focus (Base UI): name it with aria-label and set orientation to match.
- Toggles use aria-pressed; a toolbar toggle group is role="group" and needs its own aria-label.
- tooltip and shortcut add a tooltip and aria-keyshortcuts; an icon-only button needs a tooltip or aria-label.
All exports on this page
Toolbar— Toolbar: a row (or column) of related controls with ONE tab stop (Base UI Toolbar).ToolbarButton— A button in the toolbar's arrow-key order.ToolbarGroup— A labelled cluster of controls (aria-label it, e.g.ToolbarInput— A text field in the toolbar (e.g.ToolbarLink— A link in the toolbar's arrow-key order, e.g.ToolbarSeparator— A hairline between clusters; vertical in a horizontal toolbar and vice versa.ToolbarSpacer— Pushes what follows to the far end of the toolbar (a flexible, empty gap).ToolbarToggle— A pressable toggle (aria-pressed).ToolbarToggleGroup— A set of toggles inside a toolbar.
When to use Toolbar
- Use it as an editor toolbar for a rich-text editor's formatting row, where Tab enters once and arrow keys move between Bold, Italic, alignment and menu buttons instead of tabbing through twenty controls. It is an accessible toolbar with roving tabindex: Tab enters it once and the arrow keys move between the controls.
- Use variant="floating" for a selection toolbar over text or a canvas, a glass pill that appears next to the thing being edited.
- Use orientation="vertical" for a tool palette in a design or whiteboard app, where Up and Down move between tools and tooltips open to the side.
- Skip it for a handful of unrelated buttons in a page header; plain Buttons are simpler there, and Menubar fits an application's File and Edit menus with dropdowns.
- Pair it with Menu through ToolbarButton's render prop, Tooltip text already built in through the tooltip prop, and Kbd to show a shortcut such as mod+b.
Frequently asked questions
Related pages
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .