Lesson 21/100

Tutorials React.js Tutorial

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

BeginnerIntermediateAdvancedProfessional

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.

Code
Result

What happened?

  • select value must match an option value.
  • textarea content is value=, not children text, when controlled.

Try it yourself

  1. Add a textarea for feedback.
  2. Add a select for quantity 1–5.
  3. Show desc and size below the form in a

    .

  4. Change text or labels in the example and save — watch the browser update.
  5. Break the code on purpose (remove a bracket), read the error message, then fix it.
React.js Tutorial
Course syllabus

React.js Tutorial

Module 1: React Basics & Setup
Module 2: Props, Events & Lists
Module 3: Forms & Hooks
Module 4: Routing & Data
Module 5: State & Authentication
Module 6: Architecture & React 19
Module 7: Performance
Module 8: Full-Stack & Real-Time
Module 9: Testing & Deployment
Module 10: ShopCart Projects
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details