Select & Textarea in React

From the React Components & JSX cheat sheet · Forms & Controlled Components · verified Jul 2026

Select & Textarea

Controlled select dropdowns and textareas

javascript
function Survey() {
  const [country, setCountry] = React.useState('us')
  const [comments, setComments] = React.useState('')
  
  return (
    <div>
      {/* Controlled select */}
      <select 
        value={country} 
        onChange={(e) => setCountry(e.target.value)}
      >
        <option value="us">United States</option>
        <option value="uk">United Kingdom</option>
        <option value="ca">Canada</option>
      </select>
      
      {/* Controlled textarea */}
      <textarea
        value={comments}
        onChange={(e) => setComments(e.target.value)}
        rows={4}
        placeholder="Your comments..."
      />
      
      <p>Selected: {country}</p>
      <p>Comments: {comments}</p>
    </div>
  )
}
💡 Select uses value prop, not selected attribute
📌 Textarea uses value prop, not children
⚡ Same pattern as input elements
formsselecttextarea

More React tasks

Back to the full React Components & JSX cheat sheet