Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Combobox examples · Grouped

Collapsible Groups Combobox for React

A combobox whose department groups open and close from their headings.

Framework
UI library

A department picker where each group heading is a button with a chevron. Engineering starts open and Marketing starts closed, and a click on a heading toggles its items. Use it for long grouped lists where people usually need one section and the rest can stay folded away.

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

How is the collapsed state stored?

In a record of group names, which starts with Marketing collapsed. The heading button flips the entry for its group, read from a data-group attribute.

What is in each heading?

A button inside the group label with a ChevronRightIcon when closed or a ChevronDownIcon when open, then the group name. It sets aria-expanded to match.

What happens to the items of a closed group?

They aren't rendered, so the arrow keys skip them.

Which departments are listed?

Engineering: Software, Hardware and QA. Marketing: Content, Social Media and SEO. The button shows Select department... until one is picked.

Can the headings be toggled from the keyboard?

The arrow keys move through items only, so reach the heading buttons with Tab, or click them. For a list people mostly drive by keyboard, keep the groups open.