Action Toolbar

View as Markdown

A row of grouped buttons with one Tab stop, such as formatting toggles or bulk actions.

When to use

A row of grouped buttons with one Tab stop, such as formatting toggles or bulk actions. Use Menu instead when the actions fit in one dropdown instead of a row.

Usage

import { ActionToolbar } from "./ui/uicontext/components/ActionToolbar.ts"
const Message = UiSchema.TaggedEnum({ Pressed: { value: Schema.String } })export const FileActions = (h: Html.H<typeof Message.Type>) =>	ActionToolbar(h, {		label: "File",		onPress: (value) => Message.Pressed({ value }),		items: [{ value: "download", label: "Download" }, { value: "share", label: "Share" }, { kind: "separator" }, { value: "delete", label: "Delete", tone: "danger" }],	})

Examples

Actions on selected rows

A text item says what's acted on; a spacer pushes Clear to the end. A disabled button stays in the arrow keys' order so it can be found.

API reference

Options

ActionToolbar options
NameTypeDescription
keystringNames the toolbar among others in the same view; needed for more than one.
labelrequiredstringWhat the buttons act on: "Formatting", "Selected rows".
itemsrequiredActionToolbarItem<Message>[]—
onPressrequired(value: string, pressed: boolean | undefined) => Message—
orientation"horizontal" | "vertical"—
framedbooleanA border and a fill, for a toolbar that floats or sits on its own.
disabledboolean—
styleStyle—

Keyboard and accessibility

KeysDoes
TabReach the toolbar once, on the button used last
Right arrow Left arrowMove to the next or previous button
Home EndMove to the first or last button
Enter SpacePress the button

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/action-toolbar

Source