About
A row of formatting/editing tools with a single tab stop, where arrow keys move focus, toggled tools sit recessed, and tools that don't fit collapse into a More dropdown menu that preserves their state.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Toolbar to your project and fits it to your theme.
Code
How Toolbar is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
"use client";
import {
Toolbar,
ToolbarButton,
ToolbarSeparator,
ToolbarToggleGroup,
ToolbarToggleItem,
} from "@/components/ui/toolbar";
import {
AlignCenter,
AlignJustify,
AlignLeft,
AlignRight,
Bold,
ImagePlus,
Italic,
Link2,
MessageSquarePlus,
Redo2,
Strikethrough,
Underline,
Undo2,
} from "lucide-react";
import { useState } from "react";
export default function ToolbarDemo() {
const [marks, setMarks] = useState<string[]>(["bold"]);
const [align, setAlign] = useState("left");
return (
<div className="flex w-full items-center justify-center bg-background p-10">
<Toolbar label="Formatting">
<ToolbarButton
label="Undo"
icon={<Undo2 aria-hidden="true" />}
shortcut="mod+z"
onClick={() => {}}
/>
<ToolbarButton
label="Redo"
icon={<Redo2 aria-hidden="true" />}
shortcut="mod+shift+z"
onClick={() => {}}
/>
<ToolbarSeparator />
<ToolbarToggleGroup
label="Text marks"
type="multiple"
value={marks}
onValueChange={setMarks}
>
<ToolbarToggleItem
value="bold"
label="Bold"
icon={<Bold aria-hidden="true" />}
shortcut="mod+b"
/>
<ToolbarToggleItem
value="italic"
label="Italic"
icon={<Italic aria-hidden="true" />}
shortcut="mod+i"
/>
<ToolbarToggleItem
value="underline"
label="Underline"
icon={<Underline aria-hidden="true" />}
shortcut="mod+u"
/>
<ToolbarToggleItem
value="strike"
label="Strikethrough"
icon={<Strikethrough aria-hidden="true" />}
/>
</ToolbarToggleGroup>
<ToolbarSeparator />
<ToolbarToggleGroup
label="Alignment"
type="single"
value={align}
onValueChange={setAlign}
>
<ToolbarToggleItem
value="left"
label="Align left"
icon={<AlignLeft aria-hidden="true" />}
/>
<ToolbarToggleItem
value="center"
label="Align centre"
icon={<AlignCenter aria-hidden="true" />}
/>
<ToolbarToggleItem
value="right"
label="Align right"
icon={<AlignRight aria-hidden="true" />}
/>
<ToolbarToggleItem
value="justify"
label="Justify"
icon={<AlignJustify aria-hidden="true" />}
/>
</ToolbarToggleGroup>
<ToolbarSeparator />
<ToolbarButton
label="Insert link"
icon={<Link2 aria-hidden="true" />}
onClick={() => {}}
/>
<ToolbarButton
label="Insert image"
icon={<ImagePlus aria-hidden="true" />}
onClick={() => {}}
/>
<ToolbarButton
label="Comment"
icon={<MessageSquarePlus aria-hidden="true" />}
onClick={() => {}}
/>
</Toolbar>
</div>
);
}
















