"use client"; import * as React from "react"; import { LuCheck, LuChevronsUpDown } from "react-icons/lu"; import { Button } from "@/components/ui/button"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "@/components/ui/command"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { cn } from "@/lib/utils"; interface ComboboxOption { value: string; label: string; description?: string; } interface ComboboxProps { options: ComboboxOption[]; value: string; onValueChange: (value: string) => void; placeholder?: string; searchPlaceholder?: string; className?: string; } export function Combobox({ options, value, onValueChange, placeholder = "Select option...", searchPlaceholder = "Search...", className, }: ComboboxProps) { const [open, setOpen] = React.useState(false); return ( {value ? options.find((option) => option.value === value)?.label : placeholder} No option found. {options.map((option) => ( { onValueChange(currentValue === value ? "" : currentValue); setOpen(false); }} > {option.label} {option.description && ( {option.description} )} ))} ); } const frameworks = [ { value: "next.js", label: "Next.js", }, { value: "sveltekit", label: "SvelteKit", }, { value: "nuxt.js", label: "Nuxt.js", }, { value: "remix", label: "Remix", }, { value: "astro", label: "Astro", }, ]; export function ComboboxDemo() { const [open, setOpen] = React.useState(false); const [value, setValue] = React.useState(""); return ( {value ? frameworks.find((framework) => framework.value === value)?.label : "Select framework..."} No framework found. {frameworks.map((framework) => ( { setValue(currentValue === value ? "" : currentValue); setOpen(false); }} > {framework.label} ))} ); }