BulkActionBar
The bar over a selectable table, with how many rows are selected and the actions for them. A server part; TableSelection's island writes the count, and the actions work before hydration.
Import
import { BulkActionBar } from '@nizivo/react/bulk-action-bar';
// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/bulk-action-bar.css';Static or interactive
Server. It ships no client code of its own: TableSelection, the one island of
table selection, writes its count. Before hydration the count is
hidden and the actions already work, because they submit the form the rows' checkboxes belong to.
How to choose.
Use
BulkActionBar is the bar over the table: how many rows are selected, then the actions you put in
it, such as the form the rows' boxes belong to. Place it inside TableSelection. The count ("2
selected") is written by TableSelection's island as the selection changes, and a screen reader
hears it (aria-live="polite"). Pass defaultCount, the number of rows checked when the page
renders, and the server writes the count too, so it shows before hydration and hydration leaves it
as it is; without it, the count shows once the island runs. The actions work before hydration
either way.
The bar stays in place when nothing is selected, so checking the first row does not move the
table. labels.selected (with {count}) and locale set the count's text and number, for
example labels={{ selected: '{count} ausgewählt' }} locale="de-DE". It is a server part, so a
NizivoConfig's labels do not reach it: pass labels on each instance.
Examples
Basic
The bar alone, as the server renders it: the count stays hidden until TableSelection's island writes it (the Table selection page shows it working).
import type { JSX } from 'react';
import { Button } from '@nizivo/react/button';
import { BulkActionBar } from '@nizivo/react/bulk-action-bar';
export function BulkActionBarExample(): JSX.Element {
return (
<BulkActionBar style={{ maxInlineSize: 560 }}>
<Button size="sm" variant="secondary">
Archive
</Button>
<Button size="sm" variant="critical">
Delete
</Button>
</BulkActionBar>
);
}
Props
The bar over a selectable table (D-da): how many rows are selected, then the actions. Place it inside TableSelection, whose island writes the count ("2 selected") as the selection changes and announces it (aria-live); before hydration the count is hidden and the actions already work, because they submit the form the rows' checkboxes belong to. It stays in place with no rows selected, so selecting the first one does not move the table.
Server component Renders data-slot="bulk-action-bar" with the class nz-bulk-action-bar. Props: BulkActionBarProps. Source: src/bulk-action-bar/bulk-action-bar.tsx.
| Name | Type | Default | Description |
|---|---|---|---|
children | ReactNode | – | The actions: buttons of the form the rows' checkboxes belong to, for example. |
defaultCount | number | – | How many rows are selected when the page renders (its |
labels | Partial<BulkActionBarLabels> | – |
|
locale | string | 'en-US' | BCP 47 tag for the count's number and language. |
render | RenderProp<Record<string, never>> | – | Must render a |
- Also takes every attribute of
<div>;childrenis redeclared above. (ComponentPropsWithRef<"div">)
render takes an element, or, in client code, a function of the props and no state.
Other exports
BulkActionBarLabelstypeimport type { BulkActionBarLabels } from '@nizivo/react/bulk-action-bar'BulkActionBar's own strings (§16.4): serialisable, English defaults.
Name Type Default Description selectedrequiredstring'{count} selected'The count of selected rows, with
{count}.BulkActionBarPropstypeimport type { BulkActionBarProps } from '@nizivo/react/bulk-action-bar'The props of
BulkActionBar, listed above.
Data attributes and slots
Style parts by class (.nz-<slot>) and state by data attribute. Attribute meanings come from contracts/vocabulary.json.
| Slot | Rendered by | Data attributes |
|---|---|---|
bulk-action-bar.nz-bulk-action-bar | BulkActionBarroot (takes render) | none |
bulk-action-bar-actions.nz-bulk-action-bar-actions | BulkActionBarinner element (CSS only) | none |
bulk-action-bar-count.nz-bulk-action-bar-count | BulkActionBarinner element (CSS only) | none |
bulk-action-bar-template.nz-bulk-action-bar-template | BulkActionBarinner element (CSS only) | none |
CSS hooks
Set a hook on the component's class or any ancestor to restyle it without specificity games; leave it unset for the default shown.
| Hook | Default | Read as |
|---|---|---|
--nz-bulk-action-bar-bg | --nz-bg-subtle |
|
Layers: nz.components. Classes: .nz-bulk-action-bar, .nz-bulk-action-bar-actions, .nz-bulk-action-bar-count.
Tokens this stylesheet reads (11)
--nz-bg-subtle, --nz-border-subtle, --nz-border-width-default, --nz-font-label-m-strong, --nz-radius-md, --nz-space-12, --nz-space-2, --nz-space-3, --nz-space-4, --nz-text-primary, --nz-tracking-label-m
Accessibility
Nothing in this component takes focus or keyboard input.
Keyboard
None.
Figma
Node ids from design/component-map.json, which nz gen writes from component.json. The links open the Nizivo Figma library, which may ask you to sign in.
- Canonical: none
- Ghost masters: none
Breadcrumb
Where the page sits in the site, as a navigation landmark of links around an ordered list. The last level is the current page, as text with aria-current="page"; a router's link goes in through each item's render.
Button
A native button in five variants and three sizes, with a pending state that keeps focus. Compose it into triggers and links through render.