Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Dropdown Menu examples · Actions

Batch Actions Dropdown Dropdown Menu for React

A batch actions menu for several selected items, with a count label and actions to complete, tag, export, archive or delete them.

Framework
UI library

Select 47 emails or 12 tasks and the same few actions apply to all of them. This dropdown menu opens from a Batch Actions button and starts with a label that counts the selection, then offers Mark as Complete, Mark as Incomplete, Add Tags, Export Selected, Archive Selected and a destructive Delete Selected. It fits email clients, task lists, file browsers and admin tables.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

Where does 3 items selected come from?

It's the text of the DropdownMenuLabel at the top, and the demo hardcodes it. Put your selection count there, and disable the trigger when nothing is selected so the menu can't run on an empty selection.

What actions are in the menu?

Mark as Complete and Mark as Incomplete, then a separator, then Add Tags, Export Selected and Archive Selected, then a separator and Delete Selected. The label and the first two rows share a DropdownMenuGroup, and the menu is w-56.

Which rows show a shortcut?

Export Selected shows ⌘E and Delete Selected shows ⌘⌫, each in a DropdownMenuShortcut at the end of the row. The shortcut only prints the hint: register the keys on the page yourself, since the menu is closed when people press them.

How is Delete Selected marked?

variant="destructive" on that DropdownMenuItem colors the row, after a trash icon. It doesn't ask for confirmation: open an Alert Dialog that says how many items will go before you delete them.

What does the trigger look like?

An outline Button that reads Batch Actions, with a chevron after the words. DropdownMenuTrigger renders the button through render, and the words and chevron go inside the trigger.

How do I run a batch action?

The menu closes after a choice. Run the action on your selection where your library reports the chosen item. Set onClick on each DropdownMenuItem.