# Bulk Action Bar

> The bar for selected items: how many are selected, "Clear" and the actions that work on all of them.

Component · Data · Pro kit · [Live page](https://ui.twentyfirst.media/pro/components/BulkActionBar/)

The bar for selected items: how many are selected, "Clear" and the actions that work on all of them. DataTable shows it for its own selection; on its own it serves mail lists, file browsers and any list with checkboxes.

- `count` hides the bar at 0; `onClear` shows "Clear".
- `actions`: label, icon, `danger`, `disabled`. Extra controls (a menu) go in `children`.
- Floats sticky at the bottom of its scroll area by default; `floating={false}` keeps it in the flow, e.g. above a list.

## Example

```tsx
import * as React from "react";
import { BulkActionBar, Checkbox, ListRow } from "@twentyfirstmedia/pro";

const MAILS = [
  { id: "m1", from: "Lena Hart", subject: "Quarterly numbers for the board" },
  { id: "m2", from: "Noah Berg", subject: "Re: venue for the offsite" },
  { id: "m3", from: "Billing", subject: "Your invoice for November" },
  { id: "m4", from: "Ava Brandt", subject: "Draft of the hiring plan" },
];

export default function Preview() {
  const [selected, setSelected] = React.useState<string[]>(["m1", "m3"]);
  const toggle = (id: string) =>
    setSelected((s) => (s.includes(id) ? s.filter((x) => x !== id) : [...s, id]));
  return (
    <div className="tf-panel" style={{ gap: 8, minHeight: 360 }}>
      <BulkActionBar
        floating={false}
        count={selected.length}
        onClear={() => setSelected([])}
        actions={[
          { label: "Archive", icon: "archive", onClick: () => setSelected([]) },
          { label: "Mark read", icon: "check", onClick: () => setSelected([]) },
          { label: "Delete", icon: "trash", danger: true, onClick: () => setSelected([]) },
        ]}
      />
      {MAILS.map((m) => (
        <ListRow
          key={m.id}
          leading={
            <Checkbox
              label={`Select ${m.subject}`}
              checked={selected.includes(m.id)}
              onChange={() => {
                toggle(m.id);
              }}
            />
          }
          title={m.subject}
          subtitle={m.from}
        />
      ))}
    </div>
  );
}
```

## Props

### BulkActionBar

| Prop | Type | Notes |
| --- | --- | --- |
| `count` | `number` | How many items are selected; the bar hides at 0 (unless `keepOpen`). |
| `actions?` | `BulkActionBarAction[]` |  |
| `onClear?` | `() => void` | Shows "Clear" and is called by it. |
| `label?` | `string` | Accessible name of the toolbar (default "Bulk actions"). |
| `keepOpen?` | `boolean` | Stays visible with 0 selected (e.g. while an exit animation runs in your list). |
| `floating?` | `boolean` | Default: the bar floats, sticky at the bottom of its scroll area (as in DataTable). `false` keeps it in the flow, e.g. at the top of a mail list. |
| `children?` | `ReactNode` | More controls after the actions (a menu, a select). |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### ListRow

| Prop | Type | Notes |
| --- | --- | --- |
| `avatar?` | `string` |  |
| `icon?` | `IconName` |  |
| `tint?` | `Tint \| "plain"` |  |
| `leading?` | `ReactNode` |  |
| `title` | `ReactNode` | Required |
| `subtitle?` | `ReactNode` |  |
| `meta?` | `ReactNode` |  |
| `trailing?` | `ReactNode` |  |
| `unread?` | `boolean` |  |
| `active?` | `boolean` |  |
| `onClick?` | `() => void` |  |
| `href?` | `string` | Makes the row a link (with `linkAs` for a router's link). |
| `linkAs?` | `ElementType` |  |
| `actions?` | `ReactNode` | Buttons of the row's own (rename, remove …), outside the clickable area so nothing interactive is nested. Without `onClick` and `href` the row is not interactive at all. |
| `titleLines?` | `number` | Lines the title may take before it ends in an ellipsis (default: it wraps freely). |
| `subtitleLines?` | `number` | Lines the subtitle may take (default 1); badges and facts wrap within them. |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### Checkbox

| Prop | Type | Notes |
| --- | --- | --- |
| `name?` | `string` |  |
| `value?` | `string` |  |
| `required?` | `boolean` |  |
| `checked?` | `boolean` |  |
| `defaultChecked?` | `boolean` |  |
| `onChange?` | `(e: ChangeEvent<HTMLInputElement>) => void` |  |
| `children?` | `ReactNode` |  |
| `disabled?` | `boolean` |  |
| `label?` | `string` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |
