The bar that rises while rows are selected: the count, actions for them, and a way to clear.
$ pnpm dlx shadcn@latest add @dashral/action-barInstallation
$ pnpm dlx shadcn@latest add @dashral/action-barAdds the component, the components it builds on, its npm packages and the theme tokens it uses. Or by its full URL: https://dashral.com/r/action-bar.json
Usage
import { Button } from "@/components/dashral/button"
import { ActionBar } from "@/components/dashral/action-bar"
<ActionBar
open={selected.length > 0}
count={selected.length}
onClear={() => setSelected([])}
actions={<Button variant="ghost" size="sm" onClick={() => archive(selected)}>Archive</Button>}
/>Using the npm package? Import from @dashral/ui/components/action-bar instead, here and in the examples; the rest is the same.
Examples
API reference
ActionBar
Also takes every prop of <div>(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
open | booleanWhether it shows: usually while something is selected. Required. | — |
count | numberHow many are selected: "3 selected", in the locale's plural. | — |
label | ReactNodeIn place of "3 selected". | — |
actions | ReactNodeThe buttons for the selection. Required. | — |
onClear | () => voidShows an × that clears the selection; Escape inside the bar calls it too. | — |
position | "fixed" | "inline"Floating at the bottom of the window, centred; or in the page's flow. | "fixed" |
aria-label | stringNames the toolbar. | "Actions for the selection" |
classNames | { label, actions }Classes for each part. | — |
className | stringExtra classes, merged with cn() so yours win. | — |
Keyboard
| Keys | Action |
|---|---|
| Tab | Into the bar's actions |
| Escape | Clear the selection (with onClear) |
Accessibility
- role="toolbar", named "Actions for the selection" (translated); the count is a live region, announced as it changes.
- While closed it's inert: hidden from screen readers, out of the tab order, not clickable.
- On a phone, give the action buttons an icon and an sr-only label so the bar stays one row.
Motion
- Rises 16px and fades in on the spring (--duration-considered); leaves faster on --ease-exit. It keeps the last count while it leaves. With reduced motion it only fades.