JB logo

Command Palette

Search for a command to run...

yOUTUBE
Blog
PreviousNext

Searchable Select

Filterable select dropdown with search, clear button, and optional descriptions.

Installation

pnpm dlx shadcn@latest add https://jb.desishub.com/r/searchable-select.json

Usage

import { SearchableSelect } from "@/components/searchable-select";
const [value, setValue] = useState("");
 
<SearchableSelect
  options={[
    { value: "react", label: "React", description: "A JavaScript library" },
    { value: "vue", label: "Vue", description: "Progressive framework" },
    { value: "angular", label: "Angular", description: "Platform by Google" },
  ]}
  value={value}
  onValueChange={setValue}
  placeholder="Select a framework"
  clearable
/>;

Props

PropTypeDefaultDescription
optionsSearchableSelectOption[]-Available options.
valuestring-Selected value.
onValueChange(value: string) => void-Called on selection change.
placeholderstring"Select an option"Placeholder text.
emptyMessagestring"No results found."Message when no search results.
clearablebooleanfalseShow a clear button.
disabledbooleanfalseDisable the select.