Select

Select is a component used for allowing a user to choose values from a list of options.

Usage

import { Select } from "@yamada-ui/react"
<Select.Root>
  <Select.Group>
    <Select.Option />
    <Select.Label />
  </Select.Group>
  <Select.Separator />
</Select.Root>

Group Options

Use Items

Change Variant

Change Size

Change Color Scheme

Set Default Value

To set a default value, set a value in defaultValue.

Enable Multiple Selection

To enable multiple selection, set multiple to true.

Limit Maximum Selection Count

To limit the maximum selection count, set a number to max.

Change Separator

To change the separator, set a string to separator. By default, , is set.

Enable Clear Button

To enable the clear button, set clearable to true.

Change Offset

To change the offset, set values to gutter or offset.

Change Animation

To change the animation, set values like "block-start" or "inline-end" to animationScheme. By default, "scale" is set.

Change Placement

To change the placement, set values like "start" or "end-end" to placement. By default, "end" is set.

Exclude Placeholder from Options

To exclude the placeholder from options, set includePlaceholder to false.

Block Scroll

To block scroll, set blockScrollOnMount to true.

Close Dropdown On Scroll

To close the dropdown on scroll, set closeOnScroll to true.

Don't Close Dropdown on Selection

To not close the dropdown on selection, set closeOnSelect to false.

Disable Close on Blur

To disable close on blur, set closeOnBlur to false.

Disable Close Dropdown on ESC Key Press

To disable close on ESC key press, set closeOnEsc to false.

Disable Options

To disable specific options, set disabled to true.

Disable

To disable, set disabled to true.

Read-Only

To read-only, set readOnly to true.

Invalid

To make invalid, set invalid to true.

Change Border Color

To change the border color, set a value to focusBorderColor or errorBorderColor.

Customize Icon

Customize Option Icon

Customize Multiple Selection Display

Control

Props

Accessibility

The Select follows the WAI-ARIA - Combobox Pattern for accessibility.

If you are not using Field.Root, set aria-label or aria-labelledby to Select.

<Select.Root placeholder="Select a character" aria-label="Character">
  <Select.Option value="木ノ下和也">木ノ下和也</Select.Option>
  <Select.Option value="一ノ瀬ちづる">一ノ瀬ちづる</Select.Option>
  <Select.Option value="七海麻美">七海麻美</Select.Option>
  <Select.Option value="更科瑠夏">更科瑠夏</Select.Option>
  <Select.Option value="桜沢墨">桜沢墨</Select.Option>
  <Select.Option value="八重森みに">八重森みに</Select.Option>
</Select.Root>
<VStack gap="sm">
  <Heading as="h3" id="label">
    Character
  </Heading>

  <Select.Root placeholder="Select a character" aria-labelledby="label">
    <Select.Option value="木ノ下和也">木ノ下和也</Select.Option>
    <Select.Option value="一ノ瀬ちづる">一ノ瀬ちづる</Select.Option>
    <Select.Option value="七海麻美">七海麻美</Select.Option>
    <Select.Option value="更科瑠夏">更科瑠夏</Select.Option>
    <Select.Option value="桜沢墨">桜沢墨</Select.Option>
    <Select.Option value="八重森みに">八重森みに</Select.Option>
  </Select.Root>
</VStack>

Keyboard Navigation

KeyDescriptionState
ArrowUpFocuses the previous non-disabled item. If it's the first item, focuses the last non-disabled item.-
ArrowDownFocuses the next non-disabled item. If it's the last item, focuses the first non-disabled item.-
HomeFocuses the first item that is not disabled.-
EndFocuses the last item that is not disabled.-
Space, EnterSelects the focused item and closes the listbox.closeOnSelect={true}
EscapeCloses the listbox.closeOnEsc={true}

ARIA Roles and Attributes

ComponentRoles and AttributesUsage
SelectFieldrole="combobox"Indicates that this is a combobox.
aria-activedescendantSets the id of the focused item.
aria-controlsIf the listbox is open, sets the id of the related SelectContent; when closed, sets undefined.
aria-describedbyIf Select.Root is within a Field.Root and Field.Root has an errorMessage, helperMessage, or a Field.ErrorMessage, Field.HelperMessage, sets its id.
aria-disabledSets to "true" if disabled or readOnly is set.
aria-expandedSets to "true" when the listbox is open, "false" when closed.
aria-haspopup="listbox"Indicates that a listbox exists.
aria-invalidSets to "true" if invalid is set.
aria-labelSets the value of placeholder.
aria-labelledbyIf Select.Root is within a Field.Root and Field.Root has a label or Field.Label, sets its id.
aria-readonlySets to "true" if readOnly is set.
aria-requiredSets to "true" if required is set.
SelectIconrole="button"Indicates that this is a button when clearable is set and a value is present.
aria-disabledSets to "true" when clearable is set, a value is present, and disabled or readOnly is set.
aria-labelSets to "Clear value" when clearable is set and a value is present.
SelectContentrole="listbox"Indicates that this is a listbox.
Select.Labelrole="presentation"Indicates that this is a presentation.
Select.Grouprole="group"Indicates that this is a group.
aria-labelledbySets the id of the associated Select.Label.
Select.Optionrole="option"Indicates that this is an option.
aria-disabledSets to "true" if the option is disabled.
aria-selectedSets to "true" when the option is selected, "false" when not selected.
Select.Separatorrole="separator"Indicates that this is a separator.