Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Combobox examples · Multi Select

With Clear All Functionality Combobox for React

A multi-select combobox with a button that clears every picked color at once.

Framework
UI library

A color picker with an X next to the chevron while anything is selected. One click clears every pick, instead of unpicking them one at a time. Red and Blue start selected. Use it for filters and other multi-selects people often reset.

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 the clear button sit?

In a relative wrapper around the combobox, positioned absolute end-8 so it lands just before the chevron. It's a sibling of the trigger, not inside it, since a button can't contain another button.

What does it clear?

The whole selection: the demo sets the value to an empty array, and the button goes back to Select colors....

When is it shown?

Only while at least one color is picked. With nothing to clear it's not rendered.

How is the button styled?

A ghost, pill, icon-xs Button with an XIcon. It has aria-label Clear colors, since the icon has no text.

What does the combobox button show?

2 color(s) selected and so on, or Select colors... when nothing is picked.

Which colors are listed?

Red, Blue, Green, Yellow and Purple. The search box says Search colors..., and No color found. shows when nothing matches.