Skip to content
WunderUI

Action Bar

Free

Show the actions that apply to a selection, with the count of what is selected.

npx wunderui-cli add action-bar

Playground

3 selected

Installation

bash
npx wunderui-cli add action-bar

Writes the source into your project with its dependencies and, on first use, the styles - see Installation.

Then import what you need:

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

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.

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 for

  • Toolbar for actions that are always available, with or without a selection
  • Dropdown Menu for the actions of one row, behind a button
  • Toast for a confirmation after the action ran, such as 3 files archived

Label

The label tells people what the actions act on. Show the count of selected items, with the total when the list is long, or leave the label out.

3 selected

Actions

Two to four plain buttons. Put a destructive action last, and a clear button at the end when people need a way out of the selection.

3 selected

States

A button that can't run is disabled, and one that is working shows its pending state. The bar itself has no states.

State

3 selected

Keyboard interactions

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

TaborShiftTab
Moves focus to the next or previous action in the bar, in the order they are written.
EnterorSpace
Runs the focused action.

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

Behavior and motion

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

The parts the component is made of. Each one renders a you can target from CSS.

3 selected
  • 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.

  • Optional

    The text such as 3 selected, in 14 px medium. Without a label the separator goes too.

  • Optional

    A 1 px vertical line between the label and the actions. It shows only when there is a label.

  • 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

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

  • Do

    Keep to two to four actions that all make sense for any selection. Put the destructive one last.

  • Do

    Give icon-only buttons an aria-label. The bar has no name of its own, so each button must carry its own.

  • Do

    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.

  • Do

    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

    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

    Don't leave the bar on screen when nothing is selected. A bar saying 0 selected with live buttons invites mistakes.

API reference

Action Bar is a plain container. It takes the props below and passes nothing else to its element.

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.

PropTypeDefaultDescription
labelReactNode—The text before the actions, usually the count of selected items such as . When it is set, a vertical separator follows it. Leave it out for a bar of actions only.
children requiredReactNode—The actions, laid out in one row with an 8 px gap. Use small plain buttons and icon buttons.
classNamestring—Extra classes for the bar, merged with its own. Use it for the width and the placement, such as . The bar takes no other props: , and event handlers are not passed on.

Notes for AI

Give your coding assistant the Markdown reference instead of screenshots.

MCPget_component("action-bar")
Installnpx wunderui-cli add action-bar

The full library index for assistants is at /llms.txt.