Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Combobox examples · Multi Select

With Max Selections Limit Combobox for React

A multi-select combobox that stops at three interests and disables the rest.

Framework
UI library

An interest picker capped at three. The button counts against the cap, as 2/3 selected, and once three are picked the other rows are disabled and a note says Maximum 3 selections reached. Use it where a hard limit applies, such as plan limits or a top-three choice.

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 is the limit set?

In a MAX_SELECTIONS constant of 3. The demo compares the number of picks against it on every render.

How are the other rows disabled?

When the cap is reached, every row that isn't picked is disabled. Picked rows stay enabled so they can be unpicked. Each ComboboxItem gets disabled.

Where does the limit note show?

Above the list, inside ComboboxContent, as a centered muted line. It only renders while the cap is reached.

What does the button show?

The count against the cap, as 1/3 selected, or Select interests... when nothing is picked.

Which interests are listed?

Technology, Science, Art, Music, Sports and Travel. No interest found. shows when the search matches none.

How do I free up a slot?

Pick one of the selected rows again to unpick it. The disabled rows come back as soon as the count drops below three.