<option>Link for this heading
January 6, 2025 · View on GitHub
The built-in browser <option> component lets you render an option inside a <select> box.
<select>
<option value="someOption">Some option</option>
<option value="otherOption">Other option</option>
</select>
ReferenceLink for Reference
<option>Link for this heading
The built-in browser <option> component lets you render an option inside a <select> box.
<select>
<option value="someOption">Some option</option>
<option value="otherOption">Other option</option>
</select>
PropsLink for Props
<option> supports all common element props.
Additionally, <option> supports these props:
disabled: A boolean. Iftrue, the option will not be selectable and will appear dimmed.label: A string. Specifies the meaning of the option. If not specified, the text inside the option is used.value: The value to be used when submitting the parent<select>in a form if this option is selected.
CaveatsLink for Caveats
- React does not support the
selectedattribute on<option>. Instead, pass this option’svalueto the parent<select defaultValue>for an uncontrolled select box, or<select value>for a controlled select.
UsageLink for Usage
Displaying a select box with optionsLink for Displaying a select box with options
Render a <select> with a list of <option> components inside to display a select box. Give each <option> a value representing the data to be submitted with the form.
Read more about displaying a <select> with a list of <option> components.
App.js
App.js
ResetFork
export default function FruitPicker() {
return (
<label>
Pick a fruit:
<select name="selectedFruit">
<option value="apple">Apple</option>
<option value="banana">Banana</option>
<option value="orange">Orange</option>
</select>
</label>
);
}
Copyright © Meta Platforms, Inc
no uwu plz
uwu?
Logo by@sawaratsuki1004
More
On this page
Search⌘CtrlK
-
react@19
- Overview
- Hooks
- Components
- APIs
-
react-dom@19
- Hooks
- Components
- APIs
- Client APIs
- Server APIs
- Static APIs
-
Rules of React
- Overview
-
React Server Components
- Server Components
- Server Functions
- Directives
-
Legacy APIs
- Legacy React APIs
Is this page useful?