Grouped options
Choose a value from labelled option groups. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.
"use client"
import * as React from "react"
import { Label } from "@/components/ui/label"
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
export function SelectGroupedOptions() {
const id = React.useId()
return (
<div className="flex w-full max-w-sm flex-col gap-6">
<div className="flex w-full max-w-sm flex-col gap-1.5">
<Label htmlFor="select-demo">Deployment region</Label>
<Select defaultValue="gru">
<SelectTrigger id="select-demo">
<SelectValue placeholder="Pick a region" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectLabel>South America</SelectLabel>
<SelectItem value="gru">Sao Paulo</SelectItem>
<SelectItem value="eze">Buenos Aires</SelectItem>
</SelectGroup>
<SelectGroup>
<SelectLabel>Europe</SelectLabel>
<SelectItem value="fra">Frankfurt</SelectItem>
<SelectItem value="lhr">London</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
</div>
</div>
)
}