Skip to content
Nizivo UI

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.

Server component, no client JS

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.

NameTypeDefaultDescription
childrenReactNode–

The actions: buttons of the form the rows' checkboxes belong to, for example.

defaultCountnumber–

How many rows are selected when the page renders (its defaultChecked rows): the server then writes the count, and hydration leaves it as it is. Without it, the count shows once the island runs.

labelsPartial<BulkActionBarLabels>–

labels.selected sets the count's text, for example '{count} ausgewählt'.

localestring'en-US'

BCP 47 tag for the count's number and language.

renderRenderProp<Record<string, never>>–

Must render a <div>.

  • Also takes every attribute of <div>; children is redeclared above. (ComponentPropsWithRef<"div">)

render takes an element, or, in client code, a function of the props and no state.

Other exports

BulkActionBarLabels type

import type { BulkActionBarLabels } from '@nizivo/react/bulk-action-bar'

BulkActionBar's own strings (§16.4): serialisable, English defaults.

NameTypeDefaultDescription
selectedrequiredstring'{count} selected'

The count of selected rows, with {count}.

BulkActionBarProps type

import 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.

SlotRendered byData attributes
bulk-action-bar
.nz-bulk-action-bar
BulkActionBar
root (takes render)
none
bulk-action-bar-actions
.nz-bulk-action-bar-actions
BulkActionBar
inner element (CSS only)
none
bulk-action-bar-count
.nz-bulk-action-bar-count
BulkActionBar
inner element (CSS only)
none
bulk-action-bar-template
.nz-bulk-action-bar-template
BulkActionBar
inner 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.

HookDefaultRead as
--nz-bulk-action-bar-bg--nz-bg-subtle
  • background on .nz-bulk-action-bar

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

On this page