dentil

Select Search

SelectSearch is a controlled single-select combobox for lists too long to scroll. Search by city, or by a keyword such as PST. Pass an icon component to show it before the label. Pick the selected option again to clear it.

@dentil/select-search
On this page
Result: —

Installation

pnpm dlx shadcn@latest add @dentil/select-search
npx shadcn@latest add @dentil/select-search
yarn dlx shadcn@latest add @dentil/select-search
bunx --bun shadcn@latest add @dentil/select-search

Files land in components/dentil/select-search/. Uses the stock shadcn button, command and popover, so it follows your theme.

API reference

SelectSearch

PropTypeDefaultDescription
options{ label: string; value: string; keywords?: string[]; icon?: ReactNode | ComponentType; description?: string; labelClassName?: string }[]—Options to list. Search matches the value, the label, the description and any keywords. icon is a component, such as a Lucide icon, or any node, shown before the label. description is muted text after the label, in the list only. labelClassName sizes that label, such as a fixed-width code.
valuestring | null | undefined—The selected option’s value.
onChange(value: string) => void—Called with the picked value, or '' when the selected option is picked again.
placeholderstring'Select...'Trigger label with no value.
searchPlaceholderstring'Search...'Search field placeholder.
emptyTextReactNode'No results.'Shown when nothing matches.
filter(value, search, keywords?) => number—cmdk filter. Return 0 to hide an option, and higher numbers to rank it first.
groupsSelectSearchOption[][]—Renders these groups instead of one list, with a separator between them. The separator hides while searching, and a group hides when none of its options match. options is still used for the selected label.
renderValue(selected: SelectSearchOption | undefined) => ReactNode—Trigger content in place of the selected option’s icon and label. The chevron stays.
align'start' | 'center' | 'end''start'Popover alignment against the trigger.
contentClassNamestring—Applied to the popover. It is at least as wide as the trigger; use a min-w-* class to widen it.
…propsComponentProps<'button'>—Other props (id, aria-invalid, aria-describedby, onBlur…) are passed to the trigger button.