Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Combobox examples · With States

Error State with Retry Combobox for React

A combobox whose list failed to load, with a button to retry.

Framework
UI library

What to show when the options couldn't be fetched. The popup opens on an alert icon, Failed to load, Could not fetch data and a Retry button, and Retry brings in the list. Use it wherever options come from the network, so a failed request doesn't look like an empty list.

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 does the error state start?

The demo keeps an error flag that starts on, so the error block is what you see the first time the list opens.

What does the error block contain?

An AlertCircleIcon at size-8 in text-destructive, Failed to load, Could not fetch data in muted text, and a small outline Button with a RefreshCwIcon that says Retry.

What does Retry do?

It clears the error flag, and the list of Option 1, Option 2 and Option 3 takes the block's place. In an app, run the request again from here and show the error block again if it fails.

What appears after a retry?

The normal list: search filters it, a pick shows on the button, and No results found. covers a search that matches nothing.

What does the button show before a choice?

Select option.... The error lives inside the popup, so the field itself doesn't look broken until it's opened.

How is the error announced?

The icon is decorative and hidden. The text and the Retry button are in the popup, so they're read when someone moves into it. To announce the failure as it happens, put the message in a live region.