Actions & Basics
@hacline/ui/toolbarToolbar
Group multiple editing actions into a single arrow-navigated keyboard region.
Usage
Tab into the toolbar and navigate controls with arrow keys. ToolbarButton triggers immediate actions while Toggle tracks pressed state.
"use client";
import { useState } from "react";
import { Toggle } from "@/components/ui/hacline/components/toggle";
import {
Toolbar,
ToolbarButton,
ToolbarGroup,
ToolbarSeparator,
} from "@/components/ui/hacline/components/toolbar";
export const Example = () => {
const [feedback, setFeedback] = useState("Use arrow keys to switch tools");
return (
<div className="grid justify-items-center gap-2">
<Toolbar aria-label="Annotation toolbar">
<ToolbarGroup aria-label="Annotation tools">
<Toggle
onPressedChange={(on) =>
setFeedback(on ? "Markup enabled" : "Markup disabled")
}
>
Markup
</Toggle>
<Toggle
onPressedChange={(on) =>
setFeedback(on ? "Grid visible" : "Grid hidden")
}
>
Grid
</Toggle>
</ToolbarGroup>
<ToolbarSeparator />
<ToolbarButton onClick={() => setFeedback("Annotations saved")}>
Save annotations
</ToolbarButton>
</Toolbar>
<output className="text-hl-fg-muted text-xs">{feedback}</output>
</div>
);
};Vertical Toolbar & Links
Navigate focus across two toggle actions and a navigation link using Up/Down arrow keys.
"use client";
import { Toggle } from "@/components/ui/hacline/components/toggle";
import {
Toolbar,
ToolbarLink,
ToolbarSeparator,
} from "@/components/ui/hacline/components/toolbar";
export const Example = () => (
<Toolbar aria-label="Document reader tools" orientation="vertical">
<Toggle defaultPressed>Show outline</Toggle>
<Toggle>Highlight code</Toggle>
<ToolbarSeparator />
<ToolbarLink href="/docs/components">Browse components</ToolbarLink>
</Toolbar>
);Parts
| Part | Description |
|---|---|
ToolbarButton | A button in the toolbar. Arrow keys move between it and the toolbar's other items. |
ToolbarGroup | A group of related items in the toolbar. disabled disables every item in it. |
ToolbarInput | A text field. Arrows move its caret, and leave it only from the end they point at. |
ToolbarLink | A link in the toolbar. Arrow keys move between it and the toolbar's other items. |
ToolbarSeparator | A line between groups of items. |
Props
Prop
Type