Skip to main content

Select

Select enables a user to select a single item from a list of options.

Always use a Label component to identify and describe the purpose of a select element. Selects are often used within a Form Field.

info

If you need to customize the styles of the select menu or offer multiple selections, you should use the Listbox component instead.

Live Editor
function SelectExample() {
  const [selection, setSelection] = React.useState(null);
  const updateSelection = (e) => setSelection(e.target.value);

  return (
    <Box>
      <Label htmlFor="fruit">What's your favorite fruit?</Label>

      <Select id="fruit" defaultValue="" onChange={updateSelection}>
        <option value="">Select an option...</option>
        <option value="apple">Apple</option>
        <option value="orange">Orange</option>
        <option value="banana">Banana</option>
        <option value="kiwi">Kiwi</option>
      </Select>

      {selection && (
        <Box
          p={400}
          mt={400}
          border={500}
          borderColor="container.border.base"
          borderRadius="outer"
        >
          <Text fontSize={200}>Your selection: {selection}</Text>
        </Box>
      )}
    </Box>
  );
}

Properties

NameTypeDefaultDescriptionRequired?
idstringID of the form element, should match the "for" value of the associated labelYes
namestringYes
ariaLabelstringLabel used to describe the select if not used with an accompanying visual label
ariaDescribedbystringAttribute used to associate other elements that describe the Select, like an error
childrenReact.ReactNodeYes
defaultValuestring | number | readonly string[]
valuestring | number | readonly string[]Current value of the input
requiredboolean
isInvalidboolean
autoFocusboolean
disabledboolean
inputPropsOmit<DetailedHTMLProps<SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>, "ref"> & { ...; }{}Props to spread onto the underlying input element
qaobject{}
onChange(e: SyntheticEvent<HTMLSelectElement, Event>) => void
size
| "small"
| "large"
| "default"
"default"

Properties

The Select component supports the following system props:

  • COMMON - Common styling props
info

Full property documentation will be added soon.