"use client"; import React, { useState, useEffect } from "react"; import { Check, ChevronsUpDown } from "lucide-react"; import { cn } from "../lib/utils"; import { Button } from "./button"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "./command"; interface Option { value: string; label: string; } interface ComboboxWithCreateProps { options: Option[]; onSelect: (value: string) => void; onSubmit: (newName: string) => void; placeholder?: string; emptyMessage?: string; createNewMessage?: string; className?: string; } const ComboboxWithCreate: React.FC = ({ options: initialOptions, onSelect, onSubmit, placeholder = "Select an option", emptyMessage = "No option found.", createNewMessage = "Create", className, }) => { const [options, setOptions] = useState(initialOptions); const [inputValue, setInputValue] = useState(""); useEffect(() => { setOptions(initialOptions); }, [initialOptions]); return ( setInputValue(e.currentTarget.value)} placeholder={placeholder} value={inputValue} />

Start by creating a space and adding content to it

{options.map((option, idx) => ( onSelect(option.value)} > {option.label} ))}
); }; export default ComboboxWithCreate;