TabbedCombobox

A menu with tabs on the left hand side, and items on the right hand side.

#

#

Options can display an additional accessory view before the label. You can show an image, an icon, or an icon box using the type property and the appropriate props. Use the optionAccessory prop to provide a function that returns the accessory for the option.

Tabs can also have accessories. These are specified in the tabGroups prop.

Additionally, using the showPlaceholderIcon prop will render a dotted circle in the placeholder state.

#

The "All" tab is automatically added to the combobox when the showAllTab prop is set to true. You can customize the "All" tab by providing an accessory using the allTabAccessory prop.

#

You don't have to create objects with label and value keys as shown in the examples above. TabbedCombobox supports any objects, as long as you provide a label and value for each option via optionLabel and optionValue functions. description may be replaced with the optionDescription function.

#

By default, TabbedCombobox defines the selected option as the option that has the same value as the value prop. You can override this by providing a custom isOptionEqual function.

This can be useful when you want to use this component in combination with other components that define parts of the same object.

#

TabbedCombobox supports simple string labels, as well as more complex labels.

Complex labels are supported by providing both an optionLabel to generate the rendered label, and a optionFilterValue to generate a string version of the value used for filtering.

#

#

  • When single selection is required.
  • When selecting from user-generated data, where searching might come handy for long lists.
  • When there are multiple categories of options, and switching between them provides a better browsing experience.

#

  • Use sentence case.

#

#

NameDefaultDescription
isDisabled

boolean

Determines if combobox is disabled.

isLoading

boolean

Indicates that options are being loaded.

isInvalid

boolean

Indicates that combobox is in invalid state.

isClearablefalseboolean

Determines if selection can be cleared.

isOptionDisabled

(option: Option) => boolean | string

Function to determine whether an option should be disabled. If a string is returned, it will be used as a disabled message.

emptyOptionsMessage"No options"string

Text to show inside a dropdown when there are no options.

disableSortingAndFilteringfalseboolean

Determines if the options should be sorted and filtered internally.

optionAccessory

(option: Option) => SelectOptionAccessoryType | undefined

Function to show an accessory view near the option label.

optionDescription

(option: Option) => string

Function to extract description from an option. If it's not provided, `description` field will be used as a label.

optionEquality

(optionValue: OptionValue, value: OptionValue) => boolean

Function to check if an option is equal to a value. If no function is provided, lodash `isEqual` will be used.

optionLabel

(option: Option) => string | ReactNode

Function to extract label from an option. If it's not provided, `label` field will be used as a label.

optionFilterValue

(option: Option) => string

Function to build the value used when filtering options. If it's not provided, `optionLabel` will be used as a filter value.

optionValue

(option: Option) => OptionValue

Function to extract value from an option. If it's not provided, `value` field will be used as a value.

placeholder

string

Text to show inside combobox when no option is selected.

removePortalfalseboolean

Determines if the select dropdown should be rendered in a portal.

tabGroups

Array<TabGroup<Option>>

Available options. `Option` is a generic, so type of options will be inferred.

showPlaceholderIconfalseboolean

Determines if the placeholder icon should be shown. Only available when optionAccessory is defined.

size"md""sm" | "md" | "lg"

Combobox height.

value

OptionValue | undefined

Selected option.

variant"default""default" | "alternative" | "heavy"

Determines the appearance of the combobox.

width"xs""4xs" | "3xs" | "2xs" | "xs" | "sm" | "md" | "lg" | "100%"

Combobox width.

popoverWidth"sm""sm" | "md" | "lg"

The dropdown width. If not provided, the select width will be used.

onChange

(value: OptionValue | undefined) => void

Callback for when user selects a different option or clears the selection.

onSearchUpdate

(inputValue: string) => void

Callback for when user changes the input value.

valueLabel

(option: Option) => string | ReactNode

Function to format a selected option's label. If not provided, `label` field will be used as a label.

showAllTabfalseboolean

If set, the combobox will show an All tab.

allTabAccessoryundefinedSelectOptionAccessoryType

If set, the combobox will show an All tab.

comboboxRef

RefObject<HTMLInputElement>

Reference to the comboBox element.

On this page

  • Examples
  • Accessories
  • The "All" tab
  • Custom objects
  • Custom equality
  • Complex labels
  • Guidelines
  • When to use
  • Content
  • Props
  • TabbedCombobox