--- title: "` component](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select) lets you render a select box with options. ```js ``` --- ## Reference {/*reference*/} ### ``](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select) component. ```js ``` [See more examples below.](#usage) #### Props {/*props*/} ``. When you pass `value`, you must also pass an `onChange` handler that updates the passed value. If your `` props are relevant both for uncontrolled and controlled select boxes: * [`autoComplete`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select#autocomplete): A string. Specifies one of the possible [autocomplete behaviors.](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#values) * [`autoFocus`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select#autofocus): A boolean. If `true`, React will focus the element on mount. * `children`: ``](#providing-an-initially-selected-option) for uncontrolled select boxes and [`` with a list of ` ); } ``` ```css select { margin: 5px; } ``` Unlike in HTML, passing a `selected` attribute to an individual ` --- ### Enabling multiple selection {/*enabling-multiple-selection*/} Pass `multiple={true}` to the ` ); } ``` ```css select { display: block; margin-top: 10px; width: 200px; } ``` --- ### Reading the select box value when submitting a form {/*reading-the-select-box-value-when-submitting-a-form*/} Add a [`
`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) around your select box with a [`
); } ``` ```css label, select { display: block; } label { margin-bottom: 20px; } ``` Give a `name` to your ``. The `name` you specified will be used as a key in the form data, for example `{ selectedFruit: "orange" }`. If you use `` is *uncontrolled.* Even if you [pass an initially selected value](#providing-an-initially-selected-option) like ` setSelectedFruit(e.target.value)} // ... and update the state variable on any change! > ); } ``` This is useful if you want to re-render some part of the UI in response to every selection. ```js import { useState } from 'react'; export default function FruitPicker() { const [selectedFruit, setSelectedFruit] = useState('orange'); const [selectedVegs, setSelectedVegs] = useState(['corn', 'tomato']); return ( <>

Your favorite fruit: {selectedFruit}

Your favorite vegetables: {selectedVegs.join(', ')}

); } ``` ```css select { margin-bottom: 10px; display: block; } ```
**If you pass `value` without `onChange`, it will be impossible to select an option.** When you control a select box by passing some `value` to it, you *force* it to always have the value you passed. So if you pass a state variable as a `value` but forget to update that state variable synchronously during the `onChange` event handler, React will revert the select box after every keystroke back to the `value` that you specified. Unlike in HTML, passing a `selected` attribute to an individual ` --- ## Sitemap [Overview of all docs pages](/llms.txt)