• Docs
  • Blog
    • 0.24.0

    • Switch to dark mode
    Get Started
    Components
    Styling
    Theming

    Concepts

    OverviewCompositionTesting

    Layout

    Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridLink OverlayScrollableStackWrap

    Components

    AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMenuNotificationsNumber InputPin InputProgressPrompt ModalRadioRatingSelectSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

    Utilities

    Feature FlagsForLocal StoragePortalShowsplitPropsTheme

    Combobox

    A filterable select component that allows users to search and select options.

    • npm
    • source
    • recipe
    • Ark
    import {
    Combobox,
    ComboItemGroup,
    ComboItemWithIndicator,
    ComboItemText
    } from '@cerberus/react'

    Note

    Notice the naming convention of ComboItemGroup (the abstraction) and ComboboxItemGroup the primitive.

    Usage

    The Combobox component is an abstraction component that provides a fully functional combobox. It is built on top of the Select component and allows additional functionality such as filtering.

    Hades
    Persephone
    Zeus
    Poseidon
    Hera

    With Start Icon

    To add an icon to the start position of the input, use the startIcon prop to pass in your ReactNode.

    Hades
    Persephone
    Zeus
    Poseidon
    Hera

    Grouped Items

    To group items, use the ComboItemGroup component (not ComboboxItemGroup).

    The fam
    Hades
    Persephone
    Zeus
    Poseidon
    Hera

    With Field

    Wrap the Combobox component with the Field component to add additional functionality such as error and helper text when using it in a form.

    Hades
    Persephone
    Zeus
    Poseidon
    Hera
    This is saved to your profile

    Primitives

    You can utilize the primitive components or the css prop to customize the Combobox.

    ComponentDescription
    ComboboxRootThe context provider for the combobox family
    ComboboxLabelThe label that appears above the combobox input
    ComboboxControlThe wrapper to the combobox trigger that opens the dropdown
    ComboboxInputThe input field of the combobox
    ComboboxTriggerhe trigger that opens the dropdown
    ComboboxClearTriggerThe trigger that clears the selected value
    ComboboxPositionerThe wrapper that positions the dropdown
    ComboboxContentThe content of the dropdown (i.e. the container itself)
    ComboboxItemGroupThe group of options in the dropdown
    ComboboxItemGroupLabelThe label for the group of options
    ComboboxItemThe option in the dropdown
    ComboboxItemTextThe text label of the option
    ComboboxItemIndicatorThe indicator shown when the option is selected
    Hades
    🔥
    Persephone
    🔥
    Zeus
    🔥
    Poseidon
    🔥
    Hera
    🔥

    API

    Combobox

    The Combobox component is an abstraction of our primitives and accepts the following props:

    NameDefaultDescription
    sizemdThe size of the combobox.
    startIconThe icon to display at the start of the input.
    containerdocument.bodyThe container to render the dropdown in.

    The Combobox component also accepts all the props of the ComboboxRoot primitive props

    ItemWithIndicator

    The ItemWithIndicator component is an abstraction of our primitives and accepts all the props of the ComboboxItem primitive props

    ComboItemGroup

    The ComboItemGroup component is an abstraction of our primitives and accepts the following props:

    NameDefaultDescription
    labelThe label of the group.

    The ComboItemGroup component is an abstraction of our primitives and accepts all the props of the ComboboxItemGroup primitive props

    useStatefulCollection

    The useStatefulCollection function is a utility hook that creates a collection of options and filters the list based on the user input.

    function useStatefulCollection(
    initialItems: SelectCollectionItem[] = [],
    ): StatefulCollectionReturn

    Returns

    NameDescription
    collectionThe collection of options.
    filterCharsThe filter value split into an Array of chars.
    handleInputChangeThe function to pass to onInputValueChange.

    Parts

    The ComboboxParts API is an Object containing the full family of components.

    Note

    It is best to only use the ComboboxParts if you are building a custom solution. Importing Object based components will ship every property it includes into your bundle, regardless if you use it or not.

    NameDescription
    RootThe ComboboxRoot component which is the Provider for the family.
    LabelThe ComboboxLabel component which displays the label.
    ControlThe ComboboxControl component which is the container for the visual field.
    InputThe ComboboxInput component which is the visual field.
    TriggerThe ComboboxTrigger component which is the trigger for the dropdown.
    ClearTriggerThe ComboboxClearTrigger component which is the trigger to clear the value.
    PositionerThe ComboboxPositioner component which is controls the positioning for the dropdown.
    ContentThe ComboboxContent component which is the dropdown itself.
    ItemGroupThe ComboboxItemGroup component which is the group of options in the dropdown.
    ItemGroupLabelThe ComboboxItemGroupLabel component which is the label for the group of options.
    ItemThe ComboboxItem component which is the option in the dropdown.
    ItemTextThe ComboboxItemText component which is the text label of the option.
    ItemIndicatorThe ComboboxItemIndicator component which displays based on the checked state.

    On this page

    • Edit this page on Github
    Cerberus Design System | Docs