Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Combobox examples · With States

Loading State Combobox for React

A combobox that shows skeleton rows while its options load.

Framework
UI library

A combobox that loads its options when it opens. For two seconds the popup shows four skeleton rows, then the real options appear. Use it when the list comes from a request, so the popup holds its shape instead of flashing empty.

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

When do the skeletons show?

Every time the list opens. The demo watches the open state, turns loading on, and turns it off after a two-second timer that stands in for a request. The open state comes from onOpenChange, which receives a boolean.

What do the placeholders look like?

Four Skeleton bars, h-8 w-full, in a column with gap-2 and p-2, about the height of the rows they stand in for. The column has aria-busy.

What appears when loading finishes?

Option 1, Option 2 and Option 3. Search filters them, and No results found. covers a search that matches nothing.

Does it load again on every open?

Yes, the timer starts each time the list opens, and closing the list cancels it. Keep the loaded items and skip the request on later opens if they don't change often.

What does the button show?

Select option... until something is picked, then the option.

How do I load real data?

Start the request where the timer starts, store the result and pass it to the list. Show the error state if it fails.