# Bulk action bar

A stable native toolbar for a consumer-owned selection count, clear control and contextual bulk actions.

Access: pro. Category: Essentials. Kind: composite.

## When to use

- Use it when a page needs a stable native toolbar for a consumer-owned selection count, clear control and contextual bulk actions.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose tidal-button instead when press, loading, success and disabled states is the actual interface need, rather than bulk action bar.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Bulk action bar

```sh
npx shadcn@latest add @tidal-pro/bulk-action-bar
```

Stylesheets: `components/ui/tidal.css`, `components/ui/bulk-action-bar.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/bulk-action-bar.css";
import{TidalBulkActionBar}from"./components/ui/bulk-action-bar";
export default()=><div className="tidal-scope"><TidalBulkActionBar actions={[{id:"example",label:"Demo",onAction:() => {}}]} clearLabel={"Demo"} label={"Demo"} onClear={() => {}} selectedCount={1} selectionLabel={() => "Demo"}/></div>;
```

## Structured props

- `TidalBulkActionBar.actions: ReadonlyArray<TidalBulkAction>`: Required actions value accepted by this exported component.
- `TidalBulkActionBar.clearLabel: ReactNode`: Required clear label value accepted by this exported component.
- `TidalBulkActionBar.label: string`: Required label value accepted by this exported component.
- `TidalBulkActionBar.onClear: (event: ReactMouseEvent<HTMLButtonElement>) => void`: Callback invoked when the clear interaction is proposed.
- `TidalBulkActionBar.selectedCount: number`: Required selected count value accepted by this exported component.
- `TidalBulkActionBar.selectionLabel: (selectedCount: number) => ReactNode`: Required selection label value accepted by this exported component.
- `TidalBulkActionBar.clearAccessibleLabel?: string | undefined`: Optional clear accessible label value accepted by this exported component.
- `TidalBulkActionBar.clearButtonProps?: Omit<ButtonHTMLAttributes<HTMLButtonElement>, "disabled" | "aria-disabled" | "aria-label" | "children"> | undefined`: Optional clear button props value accepted by this exported component.
- `TidalBulkActionBar.clearButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional clear button ref value accepted by this exported component.
- `TidalBulkActionBar.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalBulkActionBar.meta?: ReactNode`: Optional meta value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/bulk-action-bar.tsx) | [Manifest](https://tidalui.com/examples/bulk-action-bar.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
"use client";

import "./components/ui/tidal.css";

import { useLayoutEffect, useRef, useState } from "react";

import { TidalBulkActionBar, type TidalBulkAction } from "./components/ui/bulk-action-bar";

import "./components/ui/bulk-action-bar.css";



const tidalExampleStyles = ".tidal-scope .bulk-demo,\n.tidal-scope .bulk-demo * {\n  box-sizing: border-box;\n}\n\n.tidal-scope .bulk-demo {\n  width: 100%;\n  min-width: 0;\n  color: var(--t-ink);\n  container: bulk-demo / inline-size;\n  font-family: Inter, ui-sans-serif, system-ui, sans-serif;\n}\n\n.tidal-scope .bulk-demo-frame {\n  display: grid;\n  min-width: 0;\n  gap: 10px;\n  padding: clamp(8px, 2.8cqi, 28px);\n}\n\n.tidal-scope .bulk-demo-header,\n.tidal-scope .bulk-demo-footer {\n  display: flex;\n  min-width: 0;\n  align-items: center;\n  justify-content: space-between;\n  gap: 16px;\n}\n\n.tidal-scope .bulk-demo-header {\n  padding: 8px 2px 11px;\n}\n\n.tidal-scope .bulk-demo-header > div {\n  min-width: 0;\n}\n\n.tidal-scope .bulk-demo-header span {\n  color: var(--t-muted);\n  font-size: 11px;\n  font-weight: 720;\n  letter-spacing: 0.09em;\n  line-height: 1.4;\n  text-transform: uppercase;\n}\n\n.tidal-scope .bulk-demo-header h2 {\n  margin: 5px 0 0;\n  font-size: clamp(26px, 5cqi, 46px);\n  font-weight: 570;\n  letter-spacing: -0.055em;\n  line-height: 0.96;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .bulk-demo-header button {\n  min-width: 92px;\n  min-height: 44px;\n  flex: none;\n  padding: 8px 14px;\n  border: 1px solid var(--t-ink);\n  border-radius: 10px;\n  background: var(--t-ink);\n  color: var(--t-surface);\n  font: inherit;\n  font-size: 11px;\n  font-weight: 700;\n  cursor: pointer;\n  transition:\n    background 160ms,\n    color 160ms,\n    transform 140ms var(--t-ease-out);\n}\n\n.tidal-scope .bulk-demo-header button:hover {\n  background: var(--t-surface);\n  color: var(--t-ink);\n}\n\n.tidal-scope .bulk-demo-header button:active {\n  transform: scale(0.97);\n}\n\n.tidal-scope .bulk-demo-header button:focus-visible,\n.tidal-scope .bulk-demo-table-region:focus-visible,\n.tidal-scope .bulk-demo-table-region input:focus-visible + .bulk-demo-check {\n  outline: 2px solid var(--t-accent);\n  outline-offset: 3px;\n}\n\n.tidal-scope .bulk-demo-table-region {\n  min-width: 0;\n  overflow-x: auto;\n  border: 1px solid var(--t-border);\n  border-radius: 18px;\n  background: var(--t-surface);\n  scrollbar-width: thin;\n}\n\n.tidal-scope .bulk-demo table {\n  width: 100%;\n  min-width: 660px;\n  border-collapse: collapse;\n  text-align: start;\n}\n\n.tidal-scope .bulk-demo th,\n.tidal-scope .bulk-demo td {\n  min-width: 0;\n  padding: 11px 14px;\n  border-bottom: 1px solid var(--t-border);\n  font-size: 11px;\n  line-height: 1.4;\n  text-align: start;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .bulk-demo thead th {\n  height: 42px;\n  color: var(--t-muted);\n  font-size: 11px;\n  font-weight: 720;\n  letter-spacing: 0.08em;\n  text-transform: uppercase;\n}\n\n.tidal-scope .bulk-demo thead th:first-child,\n.tidal-scope .bulk-demo tbody td:first-child {\n  width: 66px;\n  padding-inline: 11px;\n  text-align: center;\n}\n\n.tidal-scope .bulk-demo tbody tr {\n  animation: bulk-demo-row-in 420ms var(--t-ease-out) both;\n  animation-delay: calc(min(var(--bulk-demo-index), 5) * 55ms + 90ms);\n  transition: background 180ms;\n}\n\n.tidal-scope .bulk-demo tbody tr:last-child > * {\n  border-bottom: 0;\n}\n\n.tidal-scope .bulk-demo tbody tr[data-selected] {\n  background: var(--t-subtle);\n}\n\n.tidal-scope .bulk-demo tbody th {\n  min-width: 190px;\n  font-weight: 500;\n}\n\n.tidal-scope .bulk-demo tbody th > span,\n.tidal-scope .bulk-demo tbody th > strong {\n  display: block;\n}\n\n.tidal-scope .bulk-demo tbody th > span {\n  color: var(--t-muted);\n  font-size: 11px;\n  font-variant-numeric: tabular-nums;\n  letter-spacing: 0.05em;\n}\n\n.tidal-scope .bulk-demo tbody th > strong {\n  margin-top: 3px;\n  font-size: 11px;\n}\n\n.tidal-scope .bulk-demo tbody td > span[data-status] {\n  display: inline-flex;\n  min-height: 24px;\n  align-items: center;\n  padding: 3px 8px;\n  border: 1px solid var(--t-border);\n  border-radius: 999px;\n  background: var(--t-surface);\n  font-size: 11px;\n  font-weight: 690;\n  white-space: nowrap;\n}\n\n.tidal-scope .bulk-demo tbody td > span[data-status=\"Ready\"] {\n  border-color: var(--t-ink);\n  background: var(--t-ink);\n  color: var(--t-surface);\n}\n\n.tidal-scope .bulk-demo tbody label {\n  position: relative;\n  display: inline-grid;\n  width: 44px;\n  height: 44px;\n  place-items: center;\n  cursor: pointer;\n}\n\n.tidal-scope .bulk-demo tbody input {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  opacity: 0;\n}\n\n.tidal-scope .bulk-demo-check {\n  display: grid;\n  width: 18px;\n  height: 18px;\n  place-items: center;\n  border: 1px solid var(--t-border);\n  border-radius: 5px;\n  background: var(--t-surface);\n  transition:\n    border-color 160ms,\n    background 160ms,\n    transform 140ms var(--t-ease-out);\n}\n\n.tidal-scope .bulk-demo-check::after {\n  width: 7px;\n  height: 4px;\n  border-width: 0 0 1.5px 1.5px;\n  border-style: solid;\n  border-color: var(--t-surface);\n  content: \"\";\n  opacity: 0;\n  transform: translateY(-1px) rotate(-45deg);\n}\n\n.tidal-scope .bulk-demo tbody input:checked + .bulk-demo-check {\n  border-color: var(--t-ink);\n  background: var(--t-ink);\n}\n\n.tidal-scope .bulk-demo tbody input:checked + .bulk-demo-check::after {\n  opacity: 1;\n}\n\n.tidal-scope .bulk-demo tbody label:active .bulk-demo-check {\n  transform: scale(0.9);\n}\n\n.tidal-scope .bulk-demo-sr-only {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  padding: 0;\n  margin: -1px;\n  overflow: hidden;\n  clip: rect(0, 0, 0, 0);\n  white-space: nowrap;\n  border: 0;\n}\n\n.tidal-scope .bulk-demo-footer {\n  flex-wrap: wrap;\n  padding: 3px 2px 0;\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.5;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .bulk-demo-footer output {\n  color: var(--t-ink);\n  font-weight: 680;\n}\n\n@container bulk-demo (max-width: 520px) {\n  .tidal-scope .bulk-demo-frame {\n    padding: 6px;\n  }\n\n  .tidal-scope .bulk-demo-header {\n    align-items: flex-end;\n    gap: 10px;\n  }\n\n  .tidal-scope .bulk-demo-header h2 {\n    font-size: 28px;\n  }\n\n  .tidal-scope .bulk-demo-header button {\n    min-width: 0;\n    max-width: 42%;\n    font-size: 16px;\n    overflow-wrap: anywhere;\n  }\n\n  .tidal-scope .bulk-demo table {\n    min-width: 620px;\n  }\n}\n\n@media (hover: none) and (pointer: coarse) {\n  .tidal-scope .bulk-demo-header button {\n    font-size: 16px;\n  }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .tidal-scope .bulk-demo tbody tr,\n  .tidal-scope .bulk-demo-header button,\n  .tidal-scope .bulk-demo-check {\n    animation: none;\n    transition: none;\n  }\n\n  .tidal-scope .bulk-demo-header button:active,\n  .tidal-scope .bulk-demo tbody label:active .bulk-demo-check {\n    transform: none;\n  }\n}\n\n@keyframes bulk-demo-row-in {\n  from {\n    opacity: 0;\n    transform: translateY(6px);\n  }\n  to {\n    opacity: 1;\n    transform: none;\n  }\n}";

const INITIAL_RELEASES = [
  {
    id: "REL-214",
    title: "Workspace navigation",
    owner: "Mina Cole",
    status: "Needs review",
    updated: "Today, 09:40",
  },
  {
    id: "REL-209",
    title: "Usage summary",
    owner: "Jon Bell",
    status: "Draft",
    updated: "Yesterday, 16:15",
  },
  {
    id: "REL-203",
    title: "Invoice preview",
    owner: "Inez Park",
    status: "Ready",
    updated: "Oct 12, 11:08",
  },
  {
    id: "REL-198",
    title: "Search refinements",
    owner: "Ari Moss",
    status: "Needs review",
    updated: "Oct 11, 14:22",
  },
] as const;

type ReleaseStatus = "Draft" | "Needs review" | "Ready";

type ReleaseRecord = Omit<(typeof INITIAL_RELEASES)[number], "status"> & {
  status: ReleaseStatus;
};

function ReadyIcon() {
  return (
    <svg viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path
        d="m3.5 8.2 2.8 2.7 6.2-6"
        stroke="currentColor"
        strokeWidth="1.5"
      />
    </svg>
  );
}

function ReviewIcon() {
  return (
    <svg viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path
        d="M8 2.5 13 5v3.8c0 2.2-1.6 3.8-5 4.7-3.4-.9-5-2.5-5-4.7V5l5-2.5Z"
        stroke="currentColor"
        strokeWidth="1.3"
      />
      <path d="M8 5.3v3.4M8 11h.01" stroke="currentColor" strokeWidth="1.3" />
    </svg>
  );
}

export function BulkActionBarDemo() {
  const [releases, setReleases] =
    useState<readonly ReleaseRecord[]>(INITIAL_RELEASES);
  const [selectedIds, setSelectedIds] = useState<ReadonlySet<string>>(
    () => new Set([INITIAL_RELEASES[0].id, INITIAL_RELEASES[1].id]),
  );
  const [message, setMessage] = useState("Two sample releases selected.");
  const [actionAnnouncement, setActionAnnouncement] = useState("");
  const [tableOverflows, setTableOverflows] = useState(false);
  const selectAllRef = useRef<HTMLButtonElement>(null);
  const tableRegionRef = useRef<HTMLDivElement>(null);
  const tableRef = useRef<HTMLTableElement>(null);
  const restoreSelectAllFocus = useRef(false);

  useLayoutEffect(() => {
    if (!restoreSelectAllFocus.current || selectedIds.size !== 0) return;
    restoreSelectAllFocus.current = false;
    selectAllRef.current?.focus({ preventScroll: true });
  }, [selectedIds]);

  useLayoutEffect(() => {
    const region = tableRegionRef.current;
    const table = tableRef.current;
    if (!region || !table) return;
    let active = true;
    const updateOverflow = () => {
      if (!active) return;
      setTableOverflows(region.scrollWidth > region.clientWidth + 1);
    };
    updateOverflow();
    if (typeof ResizeObserver === "undefined") {
      return () => {
        active = false;
      };
    }
    const observer = new ResizeObserver(updateOverflow);
    observer.observe(region);
    observer.observe(table);
    return () => {
      active = false;
      observer.disconnect();
    };
  }, []);

  function setSelectedStatus(status: ReleaseStatus) {
    const count = selectedIds.size;
    setReleases((current) =>
      current.map((release) =>
        selectedIds.has(release.id) ? { ...release, status } : release,
      ),
    );
    const nextMessage = `${count} sample ${count === 1 ? "release" : "releases"} marked ${status.toLowerCase()}.`;
    setMessage(nextMessage);
    setActionAnnouncement(nextMessage);
  }

  const actions: readonly TidalBulkAction[] = [
    {
      id: "ready",
      label: "Mark ready",
      icon: <ReadyIcon />,
      emphasis: "strong",
      onAction: () => setSelectedStatus("Ready"),
    },
    {
      id: "review",
      label: "Needs review",
      icon: <ReviewIcon />,
      onAction: () => setSelectedStatus("Needs review"),
    },
  ];

  return (
    <section className="bulk-demo" aria-label="Release queue preview">
      <div className="bulk-demo-frame">
        <header className="bulk-demo-header">
          <div>
            <span>October cycle</span>
            <h2>Release queue</h2>
          </div>
          <button
            ref={selectAllRef}
            type="button"
            onClick={() => {
              setSelectedIds(new Set(releases.map((release) => release.id)));
              setMessage(`All ${releases.length} sample releases selected.`);
            }}
          >
            Select all
          </button>
        </header>

        <div
          ref={tableRegionRef}
          className="bulk-demo-table-region"
          role="region"
          aria-label="Sample releases"
          tabIndex={tableOverflows ? 0 : undefined}
          data-overflow={tableOverflows || undefined}
          data-qa="bulk-demo-scroll-region"
        >
          <table ref={tableRef}>
            <thead>
              <tr>
                <th scope="col">Select</th>
                <th scope="col">Release</th>
                <th scope="col">Owner</th>
                <th scope="col">Status</th>
                <th scope="col">Updated</th>
              </tr>
            </thead>
            <tbody>
              {releases.map((release, index) => {
                const checked = selectedIds.has(release.id);
                return (
                  <tr
                    key={release.id}
                    data-selected={checked || undefined}
                    style={
                      {
                        "--bulk-demo-index": index,
                      } as React.CSSProperties
                    }
                  >
                    <td>
                      <label>
                        <input
                          type="checkbox"
                          checked={checked}
                          onChange={(event) => {
                            const next = new Set(selectedIds);
                            if (event.currentTarget.checked)
                              next.add(release.id);
                            else next.delete(release.id);
                            setSelectedIds(next);
                            setMessage(
                              `${next.size} sample ${next.size === 1 ? "release" : "releases"} selected.`,
                            );
                          }}
                        />
                        <span className="bulk-demo-check" aria-hidden="true" />
                        <span className="bulk-demo-sr-only">
                          Select {release.title}
                        </span>
                      </label>
                    </td>
                    <th scope="row">
                      <span>{release.id}</span>
                      <strong>{release.title}</strong>
                    </th>
                    <td>{release.owner}</td>
                    <td>
                      <span data-status={release.status}>{release.status}</span>
                    </td>
                    <td>{release.updated}</td>
                  </tr>
                );
              })}
            </tbody>
          </table>
        </div>

        <TidalBulkActionBar
          label="Actions for selected releases"
          selectedCount={selectedIds.size}
          selectionLabel={(count) =>
            count === 1 ? "1 release selected" : `${count} releases selected`
          }
          meta="Apply a status to the current selection"
          actions={actions}
          clearLabel="Clear"
          clearAccessibleLabel="Clear selected releases"
          onClear={() => {
            restoreSelectAllFocus.current = true;
            setSelectedIds(new Set());
            setMessage("Selection cleared.");
          }}
        />

        <footer className="bulk-demo-footer">
          <output>{message}</output>
          <span>Fictional releases for this local sample.</span>
          <span className="bulk-demo-sr-only" role="status">
            {actionAnnouncement}
          </span>
        </footer>
      </div>
    </section>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <BulkActionBarDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

label gives the toolbar its required accessible name. selectedCount is normalized to a nonnegative integer and selectionLabel renders the announced consumer-owned summary. actions are ordered native buttons with unique IDs, labels, optional accessible labels, icons, emphasis, disabled state, native attributes, refs and required onAction callbacks. clearLabel, onClear and optional clearAccessibleLabel provide a native clear button with native attributes and ref. Supplied native click handlers run first and prevention suppresses the higher action or clear callback. A zero count and the optional root disabled state native-disable every owned control while keeping the bar mounted. Optional meta and root native attributes/ref remain consumer-owned. The component performs no row mutation, selection mutation, request, route, network, storage or persistence action.
