Skip to content

Select

Download .md

A select picks one value from a short list that opens in a popup.

  • Use it for 4 to 15 options.
  • Use radio buttons for 2 or 3 options, so all are visible at once.
  • Use a Combobox when the list is long or people search it.
React
Vue
1234
  1. 1Trigger showing the value
  2. 2Chevron
  3. 3List of options
  4. 4Selected option with a check

A trigger on radius-md showing the chosen value or a placeholder, and a popup on popover with radius-lg and elevation from shadow-md. The popup renders outside the page flow, so it is never clipped by a card.

There is one style, in two trigger sizes: default and sm.

React Vue Flutter Type Default Use
items children (SelectItem) options list none The options. In React, Base UI needs items on the root.
value / defaultValue v-model / default-value initialValue string none The chosen value.
onValueChange @update:model-value onChanged function none Runs when the value changes.
placeholder item (value: null) placeholder on SelectValue placeholder text none Shown before a choice.
disabled disabled enabled: false boolean false Blocks opening.
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
const products = [
{ label: "Pilih produk", value: null },
{ label: "Loka Musik", value: "lokamusik" },
{ label: "Cover Clearance", value: "coverclearance" },
{ label: "Lokasign", value: "lokasign" },
{ label: "My Loka Link", value: "mylokalink" },
]
export default function SelectDemo() {
return (
<Select items={products}>
<SelectTrigger className="w-56" aria-label="Produk">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
{products
.filter((p) => p.value !== null)
.map((p) => (
<SelectItem key={p.value} value={p.value}>
{p.label}
</SelectItem>
))}
</SelectGroup>
</SelectContent>
</Select>
)
}
Terminal window
npx shadcn@latest add https://design.sosialoka.tech/r/react/select.json
  • The trigger has role="combobox" and opens with Enter, Space or the arrow keys.
  • Arrow keys move through options; typing jumps to a matching option; Escape closes.
  • Give the trigger a label, or an aria-label when no visible label fits.