DOM props and forms
multiple prop on select
Allows more than one selected option. For a controlled multi-select, supply an array of option values and read selectedOptions to build the next array. Repeated submitted names can be read using FormData.getAll.
Formal Syntax & Structure
react syntaxreact
<select multiple value={selected}>Working Example
Example Snippetreact
import { useState } from 'react';export default function App() { const [selected,setSelected] = useState(['wood']); return <label>Materials<select multiple value={selected} onChange={e => setSelected(Array.from(e.currentTarget.selectedOptions,o=>o.value))}><option value='wood'>Wood</option><option value='metal'>Metal</option></select></label>; }