Command Palette

Search for a command to run...

Combobox

shadcn/ui

Autocomplete input and command palette with filterable dropdown options and chips.

Combobox

import { Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList } from "@/components/optics/combobox";const frameworks = ["Next.js", "SvelteKit", "Nuxt.js", "Remix", "Astro"];<Combobox  items={[    'Next.js',    'SvelteKit',    'Nuxt.js',    'Remix',    'Astro'  ]}>  <ComboboxInput    className="w-64"    placeholder="Select a framework..."    showClear  />  <ComboboxContent>    <ComboboxEmpty>      No frameworks found.    </ComboboxEmpty>    <ComboboxList />  </ComboboxContent></Combobox>

Installation

pnpm dlx shadcn@latest add @optics/combobox

Props

<Combobox />
Name
Type
filter
(...args) => string
grid
boolean
inline
boolean
open
boolean
defaultOpen
boolean
onOpenChangeComplete
((open: boolean) => void)
locale
Intl.LocalesArgument
modal
boolean
inputRef
React.Ref<HTMLInputElement>
loopFocus
boolean
openOnInputClick
boolean
inputValue
string | number | readonly string[]
defaultInputValue
string | number | readonly string[]
items
readonly any[]
filteredItems
readonly Item[]
virtualized
boolean
limit
number
autoHighlight
boolean
highlightItemOnHover
boolean
itemToStringLabel
((itemValue: Value) => string)
itemToStringValue
((itemValue: Value) => string)
isItemEqualToValue
((itemValue: Value, value: Value) => boolean)
onOpenChange
(...args) => void
onInputValueChange
(...args) => void
onItemHighlighted
(...args) => void
onValueChange
(...args) => void
render
React.ReactElement
nativeButton
boolean
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
anchor
(...args) => Element
positionMethod
"fixed" | "absolute"
sideOffset
number
alignOffset
number
sticky
boolean
arrowPadding
number
disableAnchorTracking
boolean
index
number
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>

<ComboboxInput />
Name
Type
showTrigger
boolean(default: true)
showClear
boolean(default: false)
render
React.ReactElement
filter
(...args) => string
grid
boolean
inline
boolean
open
boolean
defaultOpen
boolean
onOpenChangeComplete
((open: boolean) => void)
locale
Intl.LocalesArgument
modal
boolean
inputRef
React.Ref<HTMLInputElement>
loopFocus
boolean
openOnInputClick
boolean
inputValue
string | number | readonly string[]
defaultInputValue
string | number | readonly string[]
items
readonly any[]
filteredItems
readonly Item[]
virtualized
boolean
limit
number
autoHighlight
boolean
highlightItemOnHover
boolean
itemToStringLabel
((itemValue: Value) => string)
itemToStringValue
((itemValue: Value) => string)
isItemEqualToValue
((itemValue: Value, value: Value) => boolean)
onOpenChange
(...args) => void
onInputValueChange
(...args) => void
onItemHighlighted
(...args) => void
onValueChange
(...args) => void
nativeButton
boolean
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
anchor
(...args) => Element
positionMethod
"fixed" | "absolute"
sideOffset
number
alignOffset
number
sticky
boolean
arrowPadding
number
disableAnchorTracking
boolean
index
number
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
<ComboboxContent />
Name
Type
side
string(default: bottom)
sideOffset
number(default: 6)
align
string(default: start)
alignOffset
number(default: 0)
anchor
(...args) => Element(default: undefined)
render
React.ReactElement
finalFocus
boolean | HTMLElement
initialFocus
boolean | HTMLElement
filter
(...args) => string
grid
boolean
inline
boolean
open
boolean
defaultOpen
boolean
onOpenChangeComplete
((open: boolean) => void)
locale
Intl.LocalesArgument
modal
boolean
inputRef
React.Ref<HTMLInputElement>
loopFocus
boolean
openOnInputClick
boolean
inputValue
string | number | readonly string[]
defaultInputValue
string | number | readonly string[]
items
readonly any[]
filteredItems
readonly Item[]
virtualized
boolean
limit
number
autoHighlight
boolean
highlightItemOnHover
boolean
itemToStringLabel
((itemValue: Value) => string)
itemToStringValue
((itemValue: Value) => string)
isItemEqualToValue
((itemValue: Value, value: Value) => boolean)
onOpenChange
(...args) => void
onInputValueChange
(...args) => void
onItemHighlighted
(...args) => void
onValueChange
(...args) => void
nativeButton
boolean
positionMethod
"fixed" | "absolute"
sticky
boolean
arrowPadding
number
disableAnchorTracking
boolean
index
number
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
<ComboboxList />
Name
Type
render
React.ReactElement
filter
(...args) => string
grid
boolean
inline
boolean
open
boolean
defaultOpen
boolean
onOpenChangeComplete
((open: boolean) => void)
locale
Intl.LocalesArgument
modal
boolean
inputRef
React.Ref<HTMLInputElement>
loopFocus
boolean
openOnInputClick
boolean
inputValue
string | number | readonly string[]
defaultInputValue
string | number | readonly string[]
items
readonly any[]
filteredItems
readonly Item[]
virtualized
boolean
limit
number
autoHighlight
boolean
highlightItemOnHover
boolean
itemToStringLabel
((itemValue: Value) => string)
itemToStringValue
((itemValue: Value) => string)
isItemEqualToValue
((itemValue: Value, value: Value) => boolean)
onOpenChange
(...args) => void
onInputValueChange
(...args) => void
onItemHighlighted
(...args) => void
onValueChange
(...args) => void
nativeButton
boolean
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
anchor
(...args) => Element
positionMethod
"fixed" | "absolute"
sideOffset
number
alignOffset
number
sticky
boolean
arrowPadding
number
disableAnchorTracking
boolean
index
number
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
<ComboboxItem />
Name
Type
render
React.ReactElement
nativeButton
boolean
index
number
filter
(...args) => string
grid
boolean
inline
boolean
open
boolean
defaultOpen
boolean
onOpenChangeComplete
((open: boolean) => void)
locale
Intl.LocalesArgument
modal
boolean
inputRef
React.Ref<HTMLInputElement>
loopFocus
boolean
openOnInputClick
boolean
inputValue
string | number | readonly string[]
defaultInputValue
string | number | readonly string[]
items
readonly any[]
filteredItems
readonly Item[]
virtualized
boolean
limit
number
autoHighlight
boolean
highlightItemOnHover
boolean
itemToStringLabel
((itemValue: Value) => string)
itemToStringValue
((itemValue: Value) => string)
isItemEqualToValue
((itemValue: Value, value: Value) => boolean)
onOpenChange
(...args) => void
onInputValueChange
(...args) => void
onItemHighlighted
(...args) => void
onValueChange
(...args) => void
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
anchor
(...args) => Element
positionMethod
"fixed" | "absolute"
sideOffset
number
alignOffset
number
sticky
boolean
arrowPadding
number
disableAnchorTracking
boolean
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
<ComboboxGroup />
Name
Type
render
React.ReactElement
items
readonly any[]
filter
(...args) => string
grid
boolean
inline
boolean
open
boolean
defaultOpen
boolean
onOpenChangeComplete
((open: boolean) => void)
locale
Intl.LocalesArgument
modal
boolean
inputRef
React.Ref<HTMLInputElement>
loopFocus
boolean
openOnInputClick
boolean
inputValue
string | number | readonly string[]
defaultInputValue
string | number | readonly string[]
filteredItems
readonly Item[]
virtualized
boolean
limit
number
autoHighlight
boolean
highlightItemOnHover
boolean
itemToStringLabel
((itemValue: Value) => string)
itemToStringValue
((itemValue: Value) => string)
isItemEqualToValue
((itemValue: Value, value: Value) => boolean)
onOpenChange
(...args) => void
onInputValueChange
(...args) => void
onItemHighlighted
(...args) => void
onValueChange
(...args) => void
nativeButton
boolean
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
anchor
(...args) => Element
positionMethod
"fixed" | "absolute"
sideOffset
number
alignOffset
number
sticky
boolean
arrowPadding
number
disableAnchorTracking
boolean
index
number
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
<ComboboxLabel />
Name
Type
render
React.ReactElement
filter
(...args) => string
grid
boolean
inline
boolean
open
boolean
defaultOpen
boolean
onOpenChangeComplete
((open: boolean) => void)
locale
Intl.LocalesArgument
modal
boolean
inputRef
React.Ref<HTMLInputElement>
loopFocus
boolean
openOnInputClick
boolean
inputValue
string | number | readonly string[]
defaultInputValue
string | number | readonly string[]
items
readonly any[]
filteredItems
readonly Item[]
virtualized
boolean
limit
number
autoHighlight
boolean
highlightItemOnHover
boolean
itemToStringLabel
((itemValue: Value) => string)
itemToStringValue
((itemValue: Value) => string)
isItemEqualToValue
((itemValue: Value, value: Value) => boolean)
onOpenChange
(...args) => void
onInputValueChange
(...args) => void
onItemHighlighted
(...args) => void
onValueChange
(...args) => void
nativeButton
boolean
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
anchor
(...args) => Element
positionMethod
"fixed" | "absolute"
sideOffset
number
alignOffset
number
sticky
boolean
arrowPadding
number
disableAnchorTracking
boolean
index
number
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
<ComboboxCollection />
Name
Type
filter
(...args) => string
grid
boolean
inline
boolean
open
boolean
defaultOpen
boolean
onOpenChangeComplete
((open: boolean) => void)
locale
Intl.LocalesArgument
modal
boolean
inputRef
React.Ref<HTMLInputElement>
loopFocus
boolean
openOnInputClick
boolean
inputValue
string | number | readonly string[]
defaultInputValue
string | number | readonly string[]
items
readonly any[]
filteredItems
readonly Item[]
virtualized
boolean
limit
number
autoHighlight
boolean
highlightItemOnHover
boolean
itemToStringLabel
((itemValue: Value) => string)
itemToStringValue
((itemValue: Value) => string)
isItemEqualToValue
((itemValue: Value, value: Value) => boolean)
onOpenChange
(...args) => void
onInputValueChange
(...args) => void
onItemHighlighted
(...args) => void
onValueChange
(...args) => void
render
React.ReactElement
nativeButton
boolean
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
anchor
(...args) => Element
positionMethod
"fixed" | "absolute"
sideOffset
number
alignOffset
number
sticky
boolean
arrowPadding
number
disableAnchorTracking
boolean
index
number
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
<ComboboxEmpty />
Name
Type
render
React.ReactElement
filter
(...args) => string
grid
boolean
inline
boolean
open
boolean
defaultOpen
boolean
onOpenChangeComplete
((open: boolean) => void)
locale
Intl.LocalesArgument
modal
boolean
inputRef
React.Ref<HTMLInputElement>
loopFocus
boolean
openOnInputClick
boolean
inputValue
string | number | readonly string[]
defaultInputValue
string | number | readonly string[]
items
readonly any[]
filteredItems
readonly Item[]
virtualized
boolean
limit
number
autoHighlight
boolean
highlightItemOnHover
boolean
itemToStringLabel
((itemValue: Value) => string)
itemToStringValue
((itemValue: Value) => string)
isItemEqualToValue
((itemValue: Value, value: Value) => boolean)
onOpenChange
(...args) => void
onInputValueChange
(...args) => void
onItemHighlighted
(...args) => void
onValueChange
(...args) => void
nativeButton
boolean
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
anchor
(...args) => Element
positionMethod
"fixed" | "absolute"
sideOffset
number
alignOffset
number
sticky
boolean
arrowPadding
number
disableAnchorTracking
boolean
index
number
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
<ComboboxSeparator />
Name
Type
render
React.ReactElement
filter
(...args) => string
grid
boolean
inline
boolean
open
boolean
defaultOpen
boolean
onOpenChangeComplete
((open: boolean) => void)
locale
Intl.LocalesArgument
modal
boolean
inputRef
React.Ref<HTMLInputElement>
loopFocus
boolean
openOnInputClick
boolean
inputValue
string | number | readonly string[]
defaultInputValue
string | number | readonly string[]
items
readonly any[]
filteredItems
readonly Item[]
virtualized
boolean
limit
number
autoHighlight
boolean
highlightItemOnHover
boolean
itemToStringLabel
((itemValue: Value) => string)
itemToStringValue
((itemValue: Value) => string)
isItemEqualToValue
((itemValue: Value, value: Value) => boolean)
onOpenChange
(...args) => void
onInputValueChange
(...args) => void
onItemHighlighted
(...args) => void
onValueChange
(...args) => void
nativeButton
boolean
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
anchor
(...args) => Element
positionMethod
"fixed" | "absolute"
sideOffset
number
alignOffset
number
sticky
boolean
arrowPadding
number
disableAnchorTracking
boolean
index
number
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
<ComboboxChips />
Name
Type
render
React.ReactElement
filter
(...args) => string
grid
boolean
inline
boolean
open
boolean
defaultOpen
boolean
onOpenChangeComplete
((open: boolean) => void)
locale
Intl.LocalesArgument
modal
boolean
inputRef
React.Ref<HTMLInputElement>
loopFocus
boolean
openOnInputClick
boolean
inputValue
string | number | readonly string[]
defaultInputValue
string | number | readonly string[]
items
readonly any[]
filteredItems
readonly Item[]
virtualized
boolean
limit
number
autoHighlight
boolean
highlightItemOnHover
boolean
itemToStringLabel
((itemValue: Value) => string)
itemToStringValue
((itemValue: Value) => string)
isItemEqualToValue
((itemValue: Value, value: Value) => boolean)
onOpenChange
(...args) => void
onInputValueChange
(...args) => void
onItemHighlighted
(...args) => void
onValueChange
(...args) => void
nativeButton
boolean
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
anchor
(...args) => Element
positionMethod
"fixed" | "absolute"
sideOffset
number
alignOffset
number
sticky
boolean
arrowPadding
number
disableAnchorTracking
boolean
index
number
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
<ComboboxChip />
Name
Type
showRemove
boolean(default: true)
render
React.ReactElement
filter
(...args) => string
grid
boolean
inline
boolean
open
boolean
defaultOpen
boolean
onOpenChangeComplete
((open: boolean) => void)
locale
Intl.LocalesArgument
modal
boolean
inputRef
React.Ref<HTMLInputElement>
loopFocus
boolean
openOnInputClick
boolean
inputValue
string | number | readonly string[]
defaultInputValue
string | number | readonly string[]
items
readonly any[]
filteredItems
readonly Item[]
virtualized
boolean
limit
number
autoHighlight
boolean
highlightItemOnHover
boolean
itemToStringLabel
((itemValue: Value) => string)
itemToStringValue
((itemValue: Value) => string)
isItemEqualToValue
((itemValue: Value, value: Value) => boolean)
onOpenChange
(...args) => void
onInputValueChange
(...args) => void
onItemHighlighted
(...args) => void
onValueChange
(...args) => void
nativeButton
boolean
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
anchor
(...args) => Element
positionMethod
"fixed" | "absolute"
sideOffset
number
alignOffset
number
sticky
boolean
arrowPadding
number
disableAnchorTracking
boolean
index
number
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
<ComboboxChipsInput />
Name
Type
render
React.ReactElement
filter
(...args) => string
grid
boolean
inline
boolean
open
boolean
defaultOpen
boolean
onOpenChangeComplete
((open: boolean) => void)
locale
Intl.LocalesArgument
modal
boolean
inputRef
React.Ref<HTMLInputElement>
loopFocus
boolean
openOnInputClick
boolean
inputValue
string | number | readonly string[]
defaultInputValue
string | number | readonly string[]
items
readonly any[]
filteredItems
readonly Item[]
virtualized
boolean
limit
number
autoHighlight
boolean
highlightItemOnHover
boolean
itemToStringLabel
((itemValue: Value) => string)
itemToStringValue
((itemValue: Value) => string)
isItemEqualToValue
((itemValue: Value, value: Value) => boolean)
onOpenChange
(...args) => void
onInputValueChange
(...args) => void
onItemHighlighted
(...args) => void
onValueChange
(...args) => void
nativeButton
boolean
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
anchor
(...args) => Element
positionMethod
"fixed" | "absolute"
sideOffset
number
alignOffset
number
sticky
boolean
arrowPadding
number
disableAnchorTracking
boolean
index
number
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
<ComboboxTrigger />
Name
Type
render
React.ReactElement
nativeButton
boolean
filter
(...args) => string
grid
boolean
inline
boolean
open
boolean
defaultOpen
boolean
onOpenChangeComplete
((open: boolean) => void)
locale
Intl.LocalesArgument
modal
boolean
inputRef
React.Ref<HTMLInputElement>
loopFocus
boolean
openOnInputClick
boolean
inputValue
string | number | readonly string[]
defaultInputValue
string | number | readonly string[]
items
readonly any[]
filteredItems
readonly Item[]
virtualized
boolean
limit
number
autoHighlight
boolean
highlightItemOnHover
boolean
itemToStringLabel
((itemValue: Value) => string)
itemToStringValue
((itemValue: Value) => string)
isItemEqualToValue
((itemValue: Value, value: Value) => boolean)
onOpenChange
(...args) => void
onInputValueChange
(...args) => void
onItemHighlighted
(...args) => void
onValueChange
(...args) => void
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
anchor
(...args) => Element
positionMethod
"fixed" | "absolute"
sideOffset
number
alignOffset
number
sticky
boolean
arrowPadding
number
disableAnchorTracking
boolean
index
number
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>
<ComboboxValue />
Name
Type
filter
(...args) => string
grid
boolean
inline
boolean
open
boolean
defaultOpen
boolean
onOpenChangeComplete
((open: boolean) => void)
locale
Intl.LocalesArgument
modal
boolean
inputRef
React.Ref<HTMLInputElement>
loopFocus
boolean
openOnInputClick
boolean
inputValue
string | number | readonly string[]
defaultInputValue
string | number | readonly string[]
items
readonly any[]
filteredItems
readonly Item[]
virtualized
boolean
limit
number
autoHighlight
boolean
highlightItemOnHover
boolean
itemToStringLabel
((itemValue: Value) => string)
itemToStringValue
((itemValue: Value) => string)
isItemEqualToValue
((itemValue: Value, value: Value) => boolean)
onOpenChange
(...args) => void
onInputValueChange
(...args) => void
onItemHighlighted
(...args) => void
onValueChange
(...args) => void
render
React.ReactElement
nativeButton
boolean
initialFocus
boolean | HTMLElement
finalFocus
boolean | HTMLElement
anchor
(...args) => Element
positionMethod
"fixed" | "absolute"
sideOffset
number
alignOffset
number
sticky
boolean
arrowPadding
number
disableAnchorTracking
boolean
index
number
keepMounted
boolean
container
HTMLElement | RefObject<HTMLElement>