ComboboxPopover
Add combobox dropdown to any button element
Source
Package
Usage
ComboboxPopover adds a dropdown with options to any element. It does not render an input,
pass your own target to ComboboxPopover.Target. The target must be a single element
or a component that accepts ref:
Data format
Pass an array of options to data:
- Use strings, numbers, or booleans when the value is also the label.
- Use an object like
{ value: 'ng', label: 'Angular' }to display a different label. Adddisabled: trueto disable the option. - To group options under a label, use
{ group: 'Frontend', items: ['React', 'Angular'] }. Each group can contain primitive values or option objects.
Searchable
Set searchable prop to add a search input to the dropdown:
Controlled search value
Use searchValue and onSearchChange props to control the search input value:
Search value: (empty)
Selected value: (none)
Sort options
Use filter prop with searchable to customize filtering and sorting:
Limit options
Use limit prop with searchable to limit the number of options displayed at a time:
Multiple selection
Set multiple prop to allow selecting multiple values, value becomes an array of strings:
Check icon
Allow deselect
By default, clicking the selected option again deselects it. Set allowDeselect={false} to prevent this:
Nothing found message
Set nothingFoundMessage prop to display a message when no options are available:
Disabled options
Groups
Render option
Use renderOption prop to customize option rendering:
Virtualized dropdown
Use virtualizer to render only the visible options. Open the popover and search for an option by number:
Large data sets
The dropdown is scrollable, use maxDropdownHeight to set its maximum height:
Control dropdown opened state
Use dropdownOpened, onDropdownOpen and onDropdownClose props to control the dropdown state:
Dropdown position
Dropdown width
By default, the dropdown width matches the target. Set a custom width with comboboxProps:
Dropdown animation
Form submission
Set name to include the selection in native form submission.
ComboboxPopover with uncontrolled forms
Use defaultValue to set the initial selection. With multiple, values are joined with a comma; change the separator with hiddenInputValuesDivider:
Styles API
ComboboxPopover supports the Styles API; you can add styles to any inner element of the component with the classNames prop. Follow the Styles API documentation to learn more.
Component Styles API
Hover or focus a selector to highlight its elements