You are viewing the older version of Fidely UI for latest visitFidely UI V2

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.ElementType—The underlying element to render.
asChildboolean—Uses the provided child element as the rendered element, merging its props and behavior.
autoFocusboolean—Whether to autofocus the input on mount.
closeOnSelectboolean—Whether the select should close after an item is selected.
collectionListCollection<T>—The collection of items.
defaultHighlightedValuestring—The initial value of the highlighted item when opened.
defaultOpenboolean—Whether the select is open by default.
defaultValuestring[][]The initial default value of the select when rendered.
disabledboolean—Whether the select is disabled.
formstring—The associated form of the select.
highlightedValuestring—The controlled highlighted item value.
idstring—The id of the select root element.
invalidboolean—Whether 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.
namestring—The name of the select when used in a form.
onHighlightChange(details: HighlightChangeDetails) => void—Called when the highlighted option changes.
onOpenChange(details: OpenChangeDetails) => void—Called when the select’s open/close state changes.
onValueChange(details: ValueChangeDetails) => void—Called when the selected value changes.
openboolean—Controls the open state of the select.
openOnClickbooleantrueWhether clicking the trigger opens the select.
positioningPositioning—The positioning options for the select dropdown.
preventScrollbooleanfalsePrevents scroll locking when open.
requiredboolean—Whether selection is required before form submission.
sameWidthbooleantrueWhether the dropdown should match the trigger width.
valuestring[]—The controlled value of the select.
widthstring | number—The width of the select trigger.

On this page