Toolbar
A row of tools that is one tab stop: arrows move between them, Home and End go to the ends.
import { Toolbar, ToolbarButton, ToolbarGroup, ToolbarSeparator, ToolbarLink } from "@forgeron/ui";import { Toolbar, ToolbarButton, ToolbarGroup, ToolbarSeparator } from "@forgeron/ui";
import { BoldIcon, ItalicIcon, Link02Icon } from "@forgeron/icons";
import { useState } from "react";
export default function Formatting() {
const [bold, setBold] = useState(true);
const [italic, setItalic] = useState(false);
return (
<Toolbar label="Text formatting">
<ToolbarGroup label="Style">
<ToolbarButton icon={BoldIcon} label="Bold" pressed={bold} onClick={() => setBold(!bold)} />
<ToolbarButton
icon={ItalicIcon}
label="Italic"
pressed={italic}
onClick={() => setItalic(!italic)}
/>
</ToolbarGroup>
<ToolbarSeparator />
<ToolbarButton icon={Link02Icon} label="Link" />
<ToolbarButton label="Clear" />
</Toolbar>
);
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
Toolbar label | string | — | Names the toolbar. |
Toolbar orientation / loop | "horizontal" | "vertical" / boolean | "horizontal" / true | Direction of the arrows; wrap around. |
ToolbarButton label | string | — | Its name; the text when there is no icon. |
ToolbarButton icon / kbd | IconDefinition / string | — | A pixel icon; a shortcut after the label. |
ToolbarButton pressed / onClick | boolean / () => void | — | pressed makes it a toggle (aria-pressed). |
ToolbarGroup label | string | — | Names tools that belong together. |
className | string | — | Extra classes. |