Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Combobox examples · Standard

With Default Selected Value Combobox for React

A combobox that starts with English already selected.

Framework
UI library

A language picker that opens on a value. English is selected from the first render, so the button shows it and the list marks it. Use it for settings with a sensible default, or to show a value that was saved earlier.

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 English selected on first render?

defaultValue is the English item.

Can it be changed afterwards?

Yes. The default is only the starting point. Picking another language replaces it.

Which languages are in the list?

English, Spanish, French, German and Italian. The search box says Search language..., and No language found. shows when nothing matches.

How is English marked when the list opens?

ComboboxItem shows its check on the selected row, so English has it until another language is picked.

How do I start from a saved value?

Pass the saved value instead of English. When it can change from outside the combobox, control the value and update it on every change.

What does the button show?

The selected language, so English at first. Select language... only shows if the value is empty.