1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"use client";
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox";
const fruits = ["Apple", "Banana", "Blueberry", "Grapes", "Pineapple"];
export default function ComboboxBasicPreview() {
return (
<div className="w-64 space-y-2">
<label id="fruit-label" htmlFor="fruit" className="text-[15px]">
Fruit
</label>
<Combobox items={fruits}>
<ComboboxInput
id="fruit"
aria-labelledby="fruit-label"
placeholder="Choose a fruit"
className="w-full"
/>
<ComboboxContent>
<ComboboxEmpty>No fruit found.</ComboboxEmpty>
<ComboboxList aria-label="Fruits">
{(fruit: string) => (
<ComboboxItem key={fruit} value={fruit}>
{fruit}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
);
}