Toolbar example

Selected row actions.

Select local review rows, archive the selection and restore it. Disabled actions stay discoverable without accepting activation.

Complete React client module · MIT · Next.js and Vite

Interactive example

Selected row actions

Select local review rows, archive the selection and restore it. Disabled actions stay discoverable without accepting activation.

Keyboard

  • Checkboxes select rows independently of toolbar navigation.
  • Tab enters the action toolbar; arrow keys visit its actions. Disabled buttons are announced but cannot run.
  • Archive clears the selection and reports the local result.

States covered

  • selection count
  • disabled group
  • focusable disabled action
  • archive and restore
  • local rows

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-toolbar-bulk-actions.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import {useState} from 'react';
import {Archive,RotateCcw} from 'lucide-react';
import {Button,Checkbox,Icon} from '@bld8/ui';
import {Toolbar,ToolbarButton,ToolbarGroup,ToolbarSeparator} from '@bld8/ui/toolbar';
const initial=[{id:'brief',label:'Product brief'},{id:'tokens',label:'Colour tokens'},{id:'review',label:'Review checklist'}];
export default function BulkToolbarExample(){
  const [rows,setRows]=useState(initial),[selected,setSelected]=useState<string[]>([]),[status,setStatus]=useState('Select rows to archive.');
  return <div style={{display:'grid',gap:16,maxWidth:560}}>
    <Toolbar label="Selected row actions">
      <span style={{padding:'0 8px',whiteSpace:'nowrap'}} aria-live="polite">{selected.length} selected</span>
      <ToolbarSeparator/>
      <ToolbarGroup disabled={!selected.length} aria-label="Selection actions"><ToolbarButton onClick={()=>{setRows(current=>current.filter(row=>!selected.includes(row.id)));setStatus('Archived '+selected.length+' local rows');setSelected([]);}}><Icon icon={Archive} size={16}/>Archive selected</ToolbarButton><ToolbarButton onClick={()=>setSelected([])}>Clear selection</ToolbarButton></ToolbarGroup>
      <ToolbarSeparator/>
      <ToolbarButton onClick={()=>{setRows(initial);setSelected([]);setStatus('All local rows restored');}}><Icon icon={RotateCcw} size={16}/>Restore rows</ToolbarButton>
    </Toolbar>
    <div style={{display:'grid',gap:12}}>{rows.map(row=><Checkbox key={row.id} label={row.label} checked={selected.includes(row.id)} onCheckedChange={checked=>setSelected(current=>checked?[...current,row.id]:current.filter(id=>id!==row.id))}/>)}</div>
    {!rows.length&&<p>No rows remain. Restore rows to try again.</p>}<p role="status">{status}</p>
    <Button variant="secondary" onClick={()=>setSelected(rows.map(row=>row.id))} disabled={!rows.length}>Select all visible rows</Button>
  </div>;
}