• 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

    Select

    The Select component is a controlled component that can be used to select one option from a set. It can be used in a group with other selects to allow for multiple selections.

    • npm
    • source
    • recipe
    • Ark
    import {
    Select,
    Option,
    OptionGroup,
    OptionGroupLabel,
    createSelectCollection
    } from '@cerberus/react'

    Usage

    The Select component is a controlled component that can be used to select one option from a set. It can be used in a group with other selects to allow for multiple selections.

    Hades
    Persephone
    Zeus
    Poseidon
    Hera

    Grouped Options

    To group options, use the OptionGroup and OptionGroupLabel components.

    The fam
    Hades
    Persephone
    Zeus
    Poseidon
    Hera

    With Dialog

    To use the Select component with a dialog, you can use the container prop to render the dropdown in the dialog dom-tree.

    Some heading

    This is a description for the dialog. You can use this space to provide more context or instructions for the user.
    Hades
    Persephone
    Zeus
    Poseidon
    Hera

    Primitives

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

    ComponentDescription
    SelectRootThe context provider for the Select family
    SelectLabelThe label that appears above the select input
    SelectControlThe wrapper to the select trigger that opens the dropdown
    SelectTriggerhe trigger that opens the dropdown
    SelectValueTextThe text that appears in the trigger
    SelectIndicatorThe indicator that appears in the trigger
    SelectClearTriggerThe trigger that clears the selected value
    SelectPositionerThe wrapper that positions the dropdown
    SelectContentThe content of the dropdown (i.e. the container itself)
    SelectItemGroupThe group of options in the dropdown
    SelectItemGroupLabelThe label for the group of options
    SelectItemThe option in the dropdown
    SelectItemTextThe text label of the option
    SelectItemIndicatorThe indicator shown when the option is selected
    SelectHiddenInputThe native select for the select group.
    The fam
    Hades
    ✓
    Persephone
    ✓
    Zeus
    ✓
    Poseidon
    ✓
    Hera
    ✓

    API

    Select

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

    NameDefaultDescription
    placeholderThe placeholder to show in the select trigger.
    size'md'The size of the select.
    collectionThe collection of options to show in the dropdown.
    containerThe container to render the dropdown in. If not provided, it will use the body component.

    The Select component also accepts all the props of the SelectRoot primitive props

    Option

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

    NameDefaultDescription
    itemThe item to show in the dropdown. SelectCollectionItem

    The Option component also accepts all the props of the SelectItem primitive props

    OptionGroup

    The OptionGroup component is an abstraction of our primitives and accepts the same props as the SelectItemGroup primitive.

    OptionGroupLabel

    The OptionGroupLabel component is an abstraction of our primitives and accepts the same props as the SelectItemGroupLabel primitive.

    createSelectCollection

    The createSelectCollection function is a utility function that creates a collection of options for the Select component.

    export function createSelectCollection(
    collection: SelectCollectionItem[],
    ): ListCollection<SelectCollectionItem> {
    return createListCollection({
    items: collection,
    })
    }

    Parts

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

    Note

    It is best to only use the SelectParts 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 SelectRoot component which is the Provider for the family.
    LabelThe SelectLabel component which displays the label and "required" notice.
    ControlThe SelectControl component which is the visual field.
    TriggerThe SelectTrigger component which is the trigger for the dropdown.
    ClearTriggerThe SelectClearTrigger component which is the trigger to clear the selected value.
    ValueTextThe SelectValueText component which displays the selected value.
    IndicatorThe SelectIndicator component which displays the trigger indicator.
    PositionerThe SelectPositioner component which is controls the positioning for the dropdown.
    ContentThe SelectContent component which is the dropdown itself.
    ItemGroupThe SelectItemGroup component which is the group of options in the dropdown.
    ItemGroupLabelThe SelectItemGroupLabel component which is the label for the group of options.
    ItemThe SelectItem component which is the option in the dropdown.
    ItemTextThe SelectItemText component which is the text label of the option.
    ItemIndicatorThe SelectItemIndicator component which displays based on the checked state.
    HiddenInputThe SelectHiddenInput component which displays the native input.

    On this page

    • Edit this page on Github
    Cerberus Design System | Docs