Single selection
Choose one framework from a short searchable list while the parent owns the value. 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 { Combobox } from "@/components/ui/combobox"
const frameworks = [
{ value: "next", label: "Next.js" },
{ value: "remix", label: "Remix" },
{ value: "astro", label: "Astro" },
{ value: "nuxt", label: "Nuxt" },
{ value: "sveltekit", label: "SvelteKit" },
]
export function ComboboxSingleSelection() {
const [value, setValue] = React.useState("next")
return (
<div className="flex w-full max-w-sm flex-col gap-6">
<div className="flex">
<Combobox
aria-label="Framework"
options={frameworks}
value={value}
onValueChange={setValue}
placeholder="Pick a framework"
searchPlaceholder="Search frameworks..."
className="w-64"
/>
</div>
</div>
)
}