Action Bar
An action bar is a contextual toolbar that appears when items are selected, showing the current selection count alongside bulk action buttons.
Use it above a list, table, gallery, or canvas where users can multi-select items and apply bulk operations such as delete, archive, move, or share. The action bar communicates how many items are affected and offers a clear way to dismiss the selection.
Implementation Notes
- Uses a
<div>withrole="toolbar"so assistive tech announces it as a grouping of actions labelprop is required and renders asaria-labelon the toolbarselectedCountis exposed viadata-selected-countfor consumer styling and testsselectedCountLabelis consumer-supplied (pre-formatted, locale-aware)- The clear-selection button renders only when both
clearSelectionLabelandonClearSelectionare provided - Bulk action buttons are children — typically
action-bar-buttoncomponents
Props
label: string (required) -- aria-label for the toolbarselectedCount: number (required) -- count of currently selected itemsselectedCountLabel: string (required) -- pre-formatted count text (e.g., "3 selected")clearSelectionLabel: string (optional) -- accessible label for the clear-selection buttononClearSelection/onclearselection: callback (optional) -- clear-selection click handlerchildren: slot -- bulk action buttons...restProps: any additional HTML attributes
Usage
<ActionBar
label="Bulk actions"
selectedCount={3}
selectedCountLabel="3 selected"
clearSelectionLabel="Clear selection"
onClearSelection={handleClear}
>
<ActionBarButton label="Delete" onClick={handleDelete}>Delete</ActionBarButton>
<ActionBarButton label="Archive" onClick={handleArchive}>Archive</ActionBarButton>
</ActionBar>
Keyboard Interactions
- Tab: Move focus into and out of the toolbar
- Arrow keys: (Consumer-provided) roving tabindex among action buttons is recommended
- Enter / Space: Activate the focused action button (native button behavior)
- Escape: (Consumer-provided) dismiss or clear selection
ARIA
role="toolbar"on the containeraria-labelprovides the accessible name (required)data-selected-countexposes selection count for styling and tests- Clear button has its own
aria-labelviaclearSelectionLabel
When to Use
- Use when users can select multiple items and apply bulk operations
- Use to surface contextual actions only while a selection exists
- Use to communicate the count of selected items unambiguously
When Not to Use
- Do not use as a primary navigation toolbar — use a TabBar or ToolBar
- Do not use when only a single item action is needed — use the row's own controls
- Do not hard-code the count text — always pass a localized
selectedCountLabel
Composition
The action bar pairs with action-bar-button:
<ActionBar label="Bulk actions" selectedCount={2} selectedCountLabel="2 selected">
<ActionBarButton label="Delete">Delete</ActionBarButton>
<ActionBarButton label="Move">Move</ActionBarButton>
</ActionBar>
Headless
Renders a <div role="toolbar"> with aria-label and data-selected-count. The visibility (show/hide based on selection), animation, positioning, and visual treatment are entirely the consumer's responsibility.
Styles
Consumer CSS targets the action-bar class. Use data-selected-count to adapt visual treatment when no items are selected. Provide a clear focus indicator on every interactive descendant.
Testing
- Verify the component renders a
<div>withrole="toolbar"and classaction-bar - Verify
aria-labelequals thelabelprop - Verify
data-selected-countequals theselectedCountprop - Verify the selectedCountLabel text is rendered
- Verify the clear button is rendered only when both
clearSelectionLabelandonClearSelectionare supplied - Verify the clear-selection handler fires when the clear button is activated
Advice
- Designers: Position the action bar predictably (top of the list or as a sticky bar). Maintain a high-contrast focus indicator.
- Developers: Format the count via
Intl.PluralRulesor your i18n library and pass the result asselectedCountLabel.
Related components
action-bar-button— one action button inside an action bar
References
- WAI-ARIA Toolbar Pattern: https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/
- Adobe Spectrum Action Bar: https://spectrum.adobe.com/page/action-bar/
- WCAG 4.1.2 Name, Role, Value: https://www.w3.org/WAI/WCAG22/Understanding/name-role-value