Bulk actions for selected rows: the ticked checkbox becomes a count ball that flies to the dock and widens into the bar.
Change the valueChange the value
October billing run
| Invoice | Customer | Status | Amount | |
|---|---|---|---|---|
| #2041€1,840.00 | Juniper Labs | Overdue | €1,840.00 | |
| #2042€920.00 | Harbor & Pine | Pending | €920.00 | |
| #2043€2,310.00 | Blue Fern Studio | Paid | €2,310.00 | |
| #2044€640.00 | Oakline Freight | Pending | €640.00 | |
| #2045€1,275.00 | Mirabel Foods | Overdue | €1,275.00 | |
| #2046€480.00 | Tallow Works | Paid | €480.00 |
Tick a row to see its bulk actions
selection-bar, lively
The bulk actions of a table or a list (invoices, team members, files): the bar that appears once rows are selected and offers what applies to all of them. It does not pop in from nowhere: a count ball rises out of the checkbox the person just ticked, flies to the dock and widens into the bar; every further tick kicks the ball and rolls the count; clearing sends the ball home into the checkbox. It is table-agnostic: pass the count and the checkbox. For actions on a single row, use a row menu (Dropdown Menu, actions preset) instead.
pnpm dlx shadcn@latest add @motionkit-pro/selection-barnpx shadcn@latest add @motionkit-pro/selection-baryarn dlx shadcn@latest add @motionkit-pro/selection-barbunx --bun shadcn@latest add @motionkit-pro/selection-barRequires a Pro license and the @motionkit-pro registry with your token. See Installation.
import { SelectionBar } from "@/components/ui/selection-bar"
export function InvoicesBulkActions() {
const [selected, setSelected] = useState<string[]>([])
const [origin, setOrigin] = useState<HTMLElement | null>(null)
return (
<SelectionBar
count={selected.length}
origin={origin} // the checkbox the person last toggled
label={(n) => (n === 1 ? "invoice" : "invoices")}
onClear={() => setSelected([])}
actions={[
{
id: "export",
label: "Export",
icon: <DownloadIcon />,
onAction: () => exportRows(selected),
},
{
id: "delete",
label: "Delete",
tone: "destructive",
confirm: "Delete {count}?",
onAction: () => deleteRows(selected),
},
]}
/>
)
}Set origin in your checkbox handlers (event.currentTarget, or a ref per row) so the ball flies from the box that was ticked; with origin={null} it rises from the dock and fades there, which is what you want after an action completes (the count rolls to 0 as the bar contracts). An action that returns a promise (any thenable) shows a spinner and aria-busy until it settles; the button stays focusable meanwhile and ignores further presses. When it resolves, the button holds a tick for about a second; when it rejects, the bar catches the rejection, keeps the selection and turns the button into "Retry" with a destructive rim until it is run again. The bar never clears the selection itself: clear it in onAction when the work is done (with origin={null}) and the bar leaves. SelectionBarAction children are a compound alternative to actions.
preset picks the layout: floating (a pill docked at the bottom centre, or position="top"), toolbar (replaces your toolbar row in place: pass the row as toolbar) or edge (a vertical pill at the right edge with icon actions and tooltips, for split views whose bottom holds a pager). container="viewport" (default) renders a fixed layer in the provider's portalContainer, so no table overflow clips the flight; container="parent" renders an absolute layer inside the nearest positioned ancestor. temperament tunes how much it moves; the look never changes.
Prop
Type
Also accepts all props of Omit<SelectionBarActionItem, "id">.
Prop
Type
Also accepts all props of Omit<ComponentProps<"div">, "children">.
The toolbar preset: the title, search and Invite row gives way to the selection bar at the same height, with "Select all" while some members are left.
Change the valueChange the value
selection-bar, lively
The edge preset docked at the right edge of a file list, next to a preview pane.
Change the valueChange the value
selection-bar, lively
toolbar named "3 invoices selected", horizontal or vertical (edge), with one tab stop and roving focus.aria-keyshortcuts) moves focus into it from anywhere and back again. If the bar leaves while focus is inside it (Clear, Escape, an action), focus returns to where it came from: the element focused before the shortcut, else the origin checkbox.aria-disabled and aria-busy, never disabled, so keyboard focus stays on it. A failed one is named "Retry Export".edge) are named by their label and show it in a tooltip on hover and focus.confirm action becomes a group named by its question with Yes and No buttons; focus lands on Yes, Escape cancels and returns to the action.destructive text and rim, never color alone (the label says it). Every button is 32 px; focus rings are ring-[3px] ring-ring/50. The count ball is decorative (aria-hidden): the number is in the toolbar's name.| Key | Action |
|---|---|
| F6 / Alt + B | From anywhere on the page: focuses the bar. Inside the bar: returns focus to where it came from |
| Tab / Shift + Tab | Enters or leaves the bar (one tab stop) |
| ArrowLeft / ArrowRight | Moves between Select all, the actions, More and Clear (ArrowUp / ArrowDown in edge) |
| Home / End | First / last button |
| Enter / Space | Runs the focused action; a confirm action opens its confirm pill with focus on Yes |
| Escape | In the confirm pill: cancels. Elsewhere: clears the selection (default); with escapeClears={false}, leaves the bar |
No flight, kick or stretch. The bar fades in and out at the dock, the count crossfades, the actions fade in place and the confirm pill crossfades, all in the 120 ms fade. Depth, hover and focus stay.
Nothing runs at rest. Motion animates transforms and opacity during a change (the flight, the bar's morph, the cascade, the kick, the digit roll) and stops. Layout is measured once per trip (the checkbox and the dock), never inside a frame loop; below 560 px of container width a ResizeObserver switches to the compact layout. Third-party code: motion, @radix-ui/react-dropdown-menu (the overflow menu) and @radix-ui/react-tooltip, used bare rather than through the MotionKit Dropdown Menu and Tooltip: those two weigh about 16 kB and 11 kB gzip on their own, past this component's 15 kB budget. The tooltip follows your theme radius (rounded-md).
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom, @radix-ui/react-dropdown-menu, @radix-ui/react-tooltip, motion.
a value change, click, press
No flight, kick or stretch: the bar fades in and out at the dock, the count crossfades, the actions fade in place and the confirm pill crossfades, all in the 120ms fade.
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)