Unlock faster development with Fidely UI Pro components Coming soon

Select

Displays a list of options for the user to pick from.

Usage

import { Select } from '@fidely-ui/react'
<Select.Root
  collection={collection}
  positioning={{ sameWidth: true }}
  maxW={'350px'}
>
  <Select.Label>Framework</Select.Label>
  <Select.Control>
    <Select.Trigger>
      <Select.ValueText placeholder="Select a Framework" />
      <Select.Indicator>
        <BiChevronDown />
      </Select.Indicator>
    </Select.Trigger>
    <Select.ClearTrigger>Clear</Select.ClearTrigger>
  </Select.Control>
  <Portal>
    <Select.Positioner>
      <Select.Content>
        <Select.ItemGroup>
          <Select.ItemGroupLabel>Frameworks</Select.ItemGroupLabel>
          <Select.Item key={item} item={item}>
            <Select.ItemText>Hello</Select.ItemText>
            <Select.ItemIndicator>✓</Select.ItemIndicator>
          </Select.Item>
        </Select.ItemGroup>
      </Select.Content>
    </Select.Positioner>
  </Portal>
  <Select.HiddenSelect />
</Select.Root>

Examples

Variants

Use the variant prop to change the appearance of the Select component.

Sizes

Use the size prop to adjust the size of the Select component.

Option Group

Use the Select.ItemGroup component to group related select options.

Controlled

Use the value and onValueChange props to control the select component.

Disabled

Use the value and onValueChange props to control the select component.

Multiple

Use the multiple prop to allow multiple selections.

Icon

Render your icon with Select.Indicator or Select.ClearTriggerr to use your custom icon.

Invalid

Pass the invalid prop to the Select.Root.

Positioning

Use the positioning prop to control the underlying floating-ui options of the select component.

ClearTrigger

Render the Select.ClearTrigger component to show a clear button. Clicking the clear button will clear the selected value.

Props

Root

PropTypeDefaultDescription
asReact.ElementTypeThe underlying element to render.
asChildbooleanUses the provided child element as the rendered element, merging its props and behavior.
autoFocusbooleanWhether to autofocus the input on mount.
closeOnSelectbooleanWhether the select should close after an item is selected.
collectionListCollection<T>The collection of items.
defaultHighlightedValuestringThe initial value of the highlighted item when opened.
defaultOpenbooleanWhether the select is open by default.
defaultValuestring[][]The initial default value of the select when rendered.
disabledbooleanWhether the select is disabled.
formstringThe associated form of the select.
highlightedValuestringThe controlled highlighted item value.
idstringThe id of the select root element.
invalidbooleanWhether the select is in an invalid state. Adds data-invalid and aria-invalid.
loopbooleantrueWhether navigation wraps around when reaching the first or last item.
multiplebooleanfalseWhether multiple values can be selected.
namestringThe name of the select when used in a form.
onHighlightChange(details: HighlightChangeDetails) => voidCalled when the highlighted option changes.
onOpenChange(details: OpenChangeDetails) => voidCalled when the select’s open/close state changes.
onValueChange(details: ValueChangeDetails) => voidCalled when the selected value changes.
openbooleanControls the open state of the select.
openOnClickbooleantrueWhether clicking the trigger opens the select.
positioningPositioningThe positioning options for the select dropdown.
preventScrollbooleanfalsePrevents scroll locking when open.
requiredbooleanWhether selection is required before form submission.
sameWidthbooleantrueWhether the dropdown should match the trigger width.
valuestring[]The controlled value of the select.
widthstring | numberThe width of the select trigger.

On this page