# Action Bar

A bar of bulk actions for a selection. It sits where you place it, so fix it to the bottom of the page yourself if it should float.

- Category: Core Elements
- Page: https://wunderui.com/components/action-bar
- Tier: Free

## Install

```bash
npx wunderui-cli add action-bar
```

## Import

```tsx
import { ActionBar } from "@/components/wunderui/action-bar"
```

## Minimal usage

Then use it:

```tsx
import { ActionBar } from "@/components/ui/action-bar"
import { Button } from "@/components/ui/button"

export function SelectionBar() {
  return (
    <ActionBar label="3 selected">
      <Button variant="plain" size="sm">
        Archive
      </Button>
      <Button variant="plain" size="sm">
        Delete
      </Button>
    </ActionBar>
  )
}
```

Expected result: You should see one bar with the label 3 selected, a vertical line and two buttons, Archive and Delete.

## Usage

```tsx
import { ActionBar } from "@/components/ui/action-bar"
import { Button } from "@/components/ui/button"

export function Example() {
  return (
    <ActionBar label="3 selected">
      <Button variant="plain" size="sm">
        Archive
      </Button>
      <Button variant="plain" size="sm">
        Delete
      </Button>
    </ActionBar>
  )
}
```

## When to use

### Use Action Bar for

- Bulk actions on rows someone selected in a list or table, such as export, archive or move
- Actions on a multi-selection of files, messages or cards
- A short set of actions that all apply to the whole selection

### Use something else

- [Toolbar](https://wunderui.com/components/toolbar) for actions that are always available, with or without a selection
- [Dropdown Menu](https://wunderui.com/components/dropdown-menu) for the actions of one row, behind a button
- [Toast](https://wunderui.com/components/toast) for a confirmation after the action ran, such as 3 files archived

## Keyboard

The bar is a plain container, so the browser provides focus and activation for the buttons inside it.

| Key | Action |
|---|---|
| `Tab` or `Shift+Tab` | Moves focus to the next or previous action in the bar, in the order they are written. |
| `Enter` or `Space` | Runs the focused action. |

The bar has no toolbar role, so arrow keys do not move focus between its buttons.

## Behavior

What the bar does, and what it leaves to the page that uses it.

- **Shown by you:** The component only draws the bar. Render it while something is selected, and clear the selection once an action has run.
- **Position:** The bar does not position itself. In a flex row or a centred wrapper it hugs its content; otherwise it fills the width of its parent.
- **Label and separator:** With a label, the bar shows it and a separator before the actions. Without one, both are gone and the actions start at the left padding.
- **No name, no role:** The bar has no role or name and is not announced when it appears. Name icon-only buttons and announce the selection change yourself, for example in a polite live region.
- **Width:** The content does not wrap. A bar with a label and three text buttons is wider than 320 px, so show icon buttons on narrow screens.
- **Motion:** The bar has no motion of its own. The examples fade and slide it in from below when the first row is selected.
- **Reduced motion:** With reduced motion on, the examples skip the slide and the bar appears in place.

## Anatomy

- `ActionBar`: The bar itself: a bordered card row with a shadow. It does not position or animate itself, so place it yourself, for example above a list or at the bottom of a table card.
- `Label`: The text such as 3 selected, in 14 px medium. Without a label the separator goes too.
- `Separator`: A 1 px vertical line between the label and the actions. It shows only when there is a label.
- `Actions`: The buttons, in one row with an 8 px gap. Use small plain buttons and icon buttons; 8 px of right padding keeps a last icon button even.

## Best practices

### When to use

- Use an Action Bar for bulk actions on rows someone has selected: export, archive, delete. For actions that are always available, use Toolbar.

### Do

- Show the bar only while something is selected and put the count in the label, like 3 selected. The count tells people what the buttons act on.
- Keep to two to four actions that all make sense for any selection. Put the destructive one last.
- Give icon-only buttons an aria-label. The bar has no name of its own, so each button must carry its own.
- Place the bar yourself: above the list, or fixed and centred near the bottom. Reserve its room so content does not jump when it appears.
- Switch to icon buttons on narrow screens. The bar does not wrap, and a label with three text buttons is wider than 320 px.

### Don't

- Don't run a destructive bulk action straight from the bar. Confirm it in an Alert Dialog that says how many items go, like Delete 3 invoices?
- Don't use the bar for one-off page actions such as Save or Share. Those belong in the page header or a toolbar.
- Don't leave the bar on screen when nothing is selected. A bar saying 0 selected with live buttons invites mistakes.

## API reference

### ActionBar

| Prop | Type | Default | Description |
|---|---|---|---|
| children* | ReactNode |  | The actions, laid out in one row with an 8 px gap. Use small plain buttons and icon buttons. |
| className | string |  | Extra classes for the bar, merged with its own. Use it for the width and the placement, such as `w-fit`. The bar takes no other props: `style`, `id` and event handlers are not passed on. |
| label | ReactNode |  | The text before the actions, usually the count of selected items such as `3 selected`. When it is set, a vertical separator follows it. Leave it out for a bar of actions only. |

## Examples

### Label: count, count of total and none

```tsx
import { ActionBar } from "@/components/ui/action-bar"
import { Button } from "@/components/ui/button"

export function Example() {
  return (
    <ActionBar label="3 selected">
      <Button variant="plain" size="sm">
        Archive
      </Button>
      <Button variant="plain" size="sm">
        Delete
      </Button>
    </ActionBar>
  )
}
```

### Actions: neutral, destructive and with clear

```tsx
import { Archive, FolderInput } from "lucide-react"
import { ActionBar } from "@/components/ui/action-bar"
import { Button } from "@/components/ui/button"

export function Example() {
  return (
    <ActionBar label="3 selected">
      <Button variant="plain" size="sm">
        <FolderInput data-icon="inline-start" />
        Move
      </Button>
      <Button variant="plain" size="sm">
        <Archive data-icon="inline-start" />
        Archive
      </Button>
    </ActionBar>
  )
}
```

### State: default, disabled action and busy action

```tsx
import { ActionBar } from "@/components/ui/action-bar"
import { Button } from "@/components/ui/button"

export function Example() {
  return (
    <ActionBar label="3 selected">
      <Button variant="plain" size="sm">
        Archive
      </Button>
      <Button variant="plain" size="sm">
        Delete
      </Button>
    </ActionBar>
  )
}
```

## In context

### Inbox: bulk actions above a list

Select conversations and the bar appears in a slot above the list. The slot keeps its height, so the list doesn't jump.

```tsx
import { useState } from "react"
import { Archive, FileText, MailOpen } from "lucide-react"
import { ActionBar } from "@/components/ui/action-bar"
import { Button } from "@/components/ui/button"
import { Checkbox } from "@/components/ui/checkbox"

const CONVERSATIONS = [
  { id: "1", title: "Churn analysis Q3", note: "Shared by Daniel Okafor", unread: true },
  { id: "2", title: "Pricing page copy", note: "Priya Raman replied", unread: true },
  { id: "3", title: "Billing migration plan", note: "Needs review from Tomás Ferreira", unread: false },
  { id: "4", title: "Onboarding emails", note: "Draft saved by Maya Kessler", unread: false },
]

export function Example() {
  const [items, setItems] = useState(CONVERSATIONS)
  const [selected, setSelected] = useState<string[]>(["1", "3"])

  const toggle = (id: string, on: boolean) =>
    setSelected((list) => (on ? [...list, id] : list.filter((item) => item !== id)))
  const archive = () => {
    setItems((list) => list.filter((item) => !selected.includes(item.id)))
    setSelected([])
  }
  const markRead = () => {
    setItems((list) => list.map((item) => (selected.includes(item.id) ? { ...item, unread: false } : item)))
    setSelected([])
  }

  return (
    <div className="flex flex-col gap-3 rounded-xl border border-border bg-card p-4">
      <div className="flex items-baseline justify-between gap-3">
        <h3 className="text-base font-semibold">Inbox</h3>
        <span className="text-xs text-text-secondary">{items.length} conversations</span>
      </div>
      {/* The slot keeps its height while the bar is away, so the list does not jump. */}
      <div className="flex h-[50px] items-center">
        {selected.length > 0 && (
          <div className="animate-in fade-in-0 slide-in-from-bottom-2 duration-base ease-entrance motion-reduce:animate-none">
            <ActionBar label={`${selected.length} selected`}>
              <Button variant="plain" size="sm" onClick={markRead}>
                <MailOpen data-icon="inline-start" />
                Mark as read
              </Button>
              <Button variant="plain" size="sm" onClick={archive}>
                <Archive data-icon="inline-start" />
                Archive
              </Button>
            </ActionBar>
          </div>
        )}
      </div>
      <div className="flex flex-col gap-0.5">
        {items.map((item) => (
          <label
            key={item.id}
            className="flex cursor-pointer items-center gap-3 rounded-lg px-3 py-2.5 transition-colors duration-fast ease-move hover:bg-bg-page motion-reduce:transition-none"
          >
            <Checkbox
              aria-label={`Select ${item.title}`}
              checked={selected.includes(item.id)}
              onCheckedChange={(checked) => toggle(item.id, Boolean(checked))}
            />
            <span className="flex size-9 shrink-0 items-center justify-center rounded-md bg-tint-indigo text-tint-text-indigo">
              <FileText className="size-[18px]" />
            </span>
            <span className="flex min-w-0 flex-1 flex-col">
              <span className={item.unread ? "truncate text-sm font-semibold" : "truncate text-sm font-medium"}>
                {item.title}
              </span>
              <span className="truncate text-xs text-text-secondary">{item.note}</span>
            </span>
          </label>
        ))}
      </div>
    </div>
  )
}
```

### Invoices: a table with select all and an anchored bar

A header checkbox selects every row, and shows a dash when only some are selected. The bar sits at the bottom of the card, and Export shows a pending and a success state.

```tsx
import { useEffect, useRef, useState } from "react"
import { Download, Send, X } from "lucide-react"
import { ActionBar } from "@/components/ui/action-bar"
import { Button } from "@/components/ui/button"
import { IconButton } from "@/components/ui/icon-button"
import { Checkbox } from "@/components/ui/checkbox"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"

const INVOICES = [
  { id: "INV-1042", customer: "Nora Lindgren", amount: "$1,842.00" },
  { id: "INV-1043", customer: "Daniel Okafor", amount: "$69.98" },
  { id: "INV-1044", customer: "Priya Raman", amount: "$249.00" },
  { id: "INV-1045", customer: "Tomás Ferreira", amount: "$1,120.50" },
  { id: "INV-1046", customer: "Maya Kessler", amount: "$389.00" },
]

export function Example() {
  const [selected, setSelected] = useState<string[]>(["INV-1042", "INV-1044"])
  const [phase, setPhase] = useState<"idle" | "pending" | "success">("idle")
  const allSelected = selected.length === INVOICES.length

  const timers = useRef<number[]>([])
  // clear the timers if the component unmounts before the export finishes
  useEffect(() => () => timers.current.forEach((timer) => window.clearTimeout(timer)), [])

  const exportSelected = () => {
    setPhase("pending")
    timers.current.push(
      window.setTimeout(() => {
        setPhase("success")
        timers.current.push(window.setTimeout(() => setPhase("idle"), 1400))
      }, 1200)
    )
  }

  return (
    <div className="overflow-hidden rounded-xl border border-border bg-card">
      <Table aria-label="Invoices">
        <TableHeader>
          <TableRow>
            <TableHead className="w-12 pl-4">
              <Checkbox
                aria-label="Select all invoices"
                checked={allSelected}
                indeterminate={selected.length > 0 && !allSelected}
                onCheckedChange={(checked) => setSelected(checked ? INVOICES.map((row) => row.id) : [])}
              />
            </TableHead>
            <TableHead>Customer</TableHead>
            <TableHead className="text-right">Amount</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {INVOICES.map((row) => {
            const on = selected.includes(row.id)
            return (
              <TableRow key={row.id} data-state={on ? "selected" : undefined}>
                <TableCell className="w-12 pl-4">
                  <Checkbox
                    aria-label={`Select ${row.id}`}
                    checked={on}
                    onCheckedChange={(checked) =>
                      setSelected((list) => (checked ? [...list, row.id] : list.filter((id) => id !== row.id)))
                    }
                  />
                </TableCell>
                <TableCell>
                  {row.customer}
                  <span className="block text-xs font-normal text-text-secondary">{row.id}</span>
                </TableCell>
                <TableCell className="text-right tabular-nums">{row.amount}</TableCell>
              </TableRow>
            )
          })}
        </TableBody>
      </Table>
      {/* The bar is anchored to the bottom of the card, in a zone that keeps its height while the bar is away. */}
      <div className="flex h-[74px] items-center justify-center border-t border-border px-3">
        {selected.length > 0 && (
          <div className="animate-in fade-in-0 slide-in-from-bottom-2 duration-base ease-entrance motion-reduce:animate-none">
            <ActionBar label={`${selected.length} of ${INVOICES.length} selected`}>
              <Button variant="plain" size="sm" phase={phase} onClick={exportSelected}>
                <Download data-icon="inline-start" />
                Export
              </Button>
              <Button variant="plain" size="sm">
                <Send data-icon="inline-start" />
                Send reminder
              </Button>
              <IconButton variant="plain" size="sm" aria-label="Clear selection" onClick={() => setSelected([])}>
                <X />
              </IconButton>
            </ActionBar>
          </div>
        )}
      </div>
    </div>
  )
}
```

### Files: confirm a destructive action

Delete in the bar opens an Alert Dialog that names how many files go. The bar never deletes by itself.

```tsx
import { useState } from "react"
import { FileText, FolderInput, Trash2 } from "lucide-react"
import { ActionBar } from "@/components/ui/action-bar"
import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogIcon,
  AlertDialogTitle,
} from "@/components/ui/alert-dialog"
import { Button } from "@/components/ui/button"
import { Checkbox } from "@/components/ui/checkbox"

const FILES = [
  { id: "1", name: "Q3 Report.pdf", meta: "PDF, 2.4 MB" },
  { id: "2", name: "Roadmap.docx", meta: "Document, 380 KB" },
  { id: "3", name: "Brand assets.zip", meta: "Archive, 18.2 MB" },
  { id: "4", name: "Invoices-2026.csv", meta: "Spreadsheet, 96 KB" },
]

export function Example() {
  const [files, setFiles] = useState(FILES)
  const [selected, setSelected] = useState<string[]>(["2", "3"])
  const [confirming, setConfirming] = useState(false)

  const count = selected.length
  const noun = count === 1 ? "file" : "files"

  return (
    <div className="flex flex-col gap-3 rounded-xl border border-border bg-card p-4">
      <div className="flex items-baseline justify-between gap-3">
        <h3 className="text-base font-semibold">Files</h3>
        <span className="text-xs text-text-secondary">{files.length} items</span>
      </div>
      <div className="flex h-[50px] items-center">
        {count > 0 && (
          <div className="animate-in fade-in-0 slide-in-from-bottom-2 duration-base ease-entrance motion-reduce:animate-none">
            <ActionBar label={`${count} selected`}>
              <Button variant="plain" size="sm">
                <FolderInput data-icon="inline-start" />
                Move
              </Button>
              <Button variant="plain" size="sm" className="text-text-error" onClick={() => setConfirming(true)}>
                <Trash2 data-icon="inline-start" />
                Delete
              </Button>
            </ActionBar>
          </div>
        )}
      </div>
      <div className="flex flex-col gap-0.5">
        {files.map((file) => (
          <label
            key={file.id}
            className="flex cursor-pointer items-center gap-3 rounded-lg px-3 py-2.5 transition-colors duration-fast ease-move hover:bg-bg-page motion-reduce:transition-none"
          >
            <Checkbox
              aria-label={`Select ${file.name}`}
              checked={selected.includes(file.id)}
              onCheckedChange={(checked) =>
                setSelected((list) => (checked ? [...list, file.id] : list.filter((id) => id !== file.id)))
              }
            />
            <span className="flex size-9 shrink-0 items-center justify-center rounded-md bg-tint-indigo text-tint-text-indigo">
              <FileText className="size-[18px]" />
            </span>
            <span className="flex min-w-0 flex-1 flex-col">
              <span className="truncate text-sm font-medium">{file.name}</span>
              <span className="truncate text-xs text-text-secondary">{file.meta}</span>
            </span>
          </label>
        ))}
      </div>
      <AlertDialog open={confirming} onOpenChange={setConfirming}>
        <AlertDialogContent size="lg">
          <AlertDialogHeader>
            <AlertDialogIcon variant="destructive" />
            <AlertDialogTitle>
              Delete {count} {noun}?
            </AlertDialogTitle>
            <AlertDialogDescription>The files move to Trash. Anyone using a shared link loses access.</AlertDialogDescription>
          </AlertDialogHeader>
          <AlertDialogFooter layout="inline">
            <AlertDialogCancel>Cancel</AlertDialogCancel>
            <AlertDialogAction
              variant="destructive"
              onClick={() => {
                setFiles((list) => list.filter((file) => !selected.includes(file.id)))
                setSelected([])
              }}
            >
              Delete {count} {noun}
            </AlertDialogAction>
          </AlertDialogFooter>
        </AlertDialogContent>
      </AlertDialog>
    </div>
  )
}
```

## For AI agents

`get_component("action-bar")`

Hand your agent this page as Markdown or the WunderUI MCP server, not a screenshot.
