Tools above a list
import { Button } from "@senvenli/react/action";
import { Input } from "@senvenli/react/form";
import { Toolbar, ToolbarSpacer } from "@senvenli/react/layout";
import { Select } from "@senvenli/react/selection";
export default function Example() {
return (
<Toolbar aria-label="Order tools">
<Input type="search" aria-label="Search orders" placeholder="Order number or customer" size="small" />
<Select
aria-label="Status"
size="small"
placeholder="All statuses"
items={[
{ id: "open", label: "Open" },
{ id: "paid", label: "Paid" },
{ id: "overdue", label: "Overdue" },
]}
/>
<ToolbarSpacer />
<Button size="small" iconBefore="download">
Export
</Button>
</Toolbar>
);
}import { Toolbar, ToolbarSpacer, BulkBar } from "@senvenli/react/layout";Examples
BulkBar
Appears while rows are selected, with their count and the actions for them.import { Button } from "@senvenli/react/action";
import { Stack } from "@senvenli/react/layout";
import { BulkBar } from "@senvenli/react/layout";
import { toast } from "@senvenli/react/overlay";
import { Checkbox, CheckboxGroup } from "@senvenli/react/selection";
import { useState } from "react";
const ORDERS = ["ORD-1040", "ORD-1039", "ORD-1038", "ORD-1037"];
export default function Example() {
const [selected, setSelected] = useState(["ORD-1040", "ORD-1038"]);
return (
<Stack space="space-200">
<CheckboxGroup label="Orders awaiting payment" value={selected} onChange={setSelected}>
{ORDERS.map((order) => (
<Checkbox key={order} value={order}>
{order}
</Checkbox>
))}
</CheckboxGroup>
{selected.length > 0 && (
<BulkBar
aria-label="Selected orders"
selectedCount={selected.length}
onClear={() => setSelected([])}
actions={
<>
<Button size="small" iconBefore="mail" onPress={() => toast.success("Reminders sent")}>
Send reminder
</Button>
<Button size="small" iconBefore="download">
Export
</Button>
</>
}
/>
)}
</Stack>
);
}Guidelines
When to use it
- Filters, search and actions above a list.
- Actions on selected rows (BulkBar).
Use something else when
- Two or three related buttons, not a full row of controls. Button group
- The actions fit under one button. Menu
Accessibility
Keyboard
| Keys | What happens |
|---|---|
| Arrow keys | Moves between controls. |
Built in
- One tab stop for the toolbar.
You provide
- A name for the toolbar.
API reference
Toolbar
| Prop | Type | Default | Description |
|---|---|---|---|
childrenRequired | React.ReactNode | – | Compact (32px) controls acting on the view below: search, filters, date range, view switch, export. |
aria-labelRequired | string | – | Names the toolbar ("Order tools"). |
childrenRequiredReact.ReactNodeCompact (32px) controls acting on the view below: search, filters, date range, view switch, export.
aria-labelRequiredstringNames the toolbar ("Order tools").
BulkBar
| Prop | Type | Default | Description |
|---|---|---|---|
selectedCountRequired | number | – | How many rows are selected; announced as it changes. |
actionsRequired | React.ReactNode | – | The bulk actions (compact Buttons): "Send reminder", "Export". |
onClearRequired | () => void | – | Clears the selection; the bar goes with it. |
aria-labelRequired | string | – | Names the bar ("Selected orders"). |
selectedCountRequirednumberHow many rows are selected; announced as it changes.
actionsRequiredReact.ReactNodeThe bulk actions (compact Buttons): "Send reminder", "Export".
onClearRequired() => voidClears the selection; the bar goes with it.
aria-labelRequiredstringNames the bar ("Selected orders").