Textarea & Select — Complete Guide
Textarea & Select — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of React.js Tutorial on Toolliyo Academy.
On this page
React.js Tutorial · Lesson 21 of 100
Textarea & Select
Beginner → Intermediate → Advanced → Professional
Beginner · 1 — Learn by example · ~6 min · Module 3: Forms & Hooks
What is this?
Textarea and select work like text inputs: controlled with value and onChange. Select uses e.target.value; textarea uses rows for height.
Why should you care?
Product descriptions, country pickers, and quantity dropdowns use these elements daily.
See it live — copy this example
Paste into src/App.jsx (or the file noted in the steps). Save and watch the browser update.
import { useState } from 'react';
function ProductForm() {
const [desc, setDesc] = useState('');
const [size, setSize] = useState('m');
return (
<>
<textarea rows={4} value={desc} onChange={e => setDesc(e.target.value)} />
<select value={size} onChange={e => setSize(e.target.value)}>
<option value="s">Small</option>
<option value="m">Medium</option>
<option value="l">Large</option>
</select>
</>
);
}
Run Example »
Edit the code and click Run to see the result update live.
What happened?
- select value must match an option value.
- textarea content is value=, not children text, when controlled.
Try it yourself
- Add a textarea for feedback.
- Add a select for quantity 1–5.
- Show desc and size below the form in a
.
- Change text or labels in the example and save — watch the browser update.
- Break the code on purpose (remove a bracket), read the error message, then fix it.
Remember
textarea and select are controlled like input. value + onChange required. select options need value attributes.