Course contentsShow
← React
Lesson 456 of 2,39613. Controlled ComponentsFree lesson

Controlled Textareas

Unlike HTML, React textareas use the value prop (not children) and work identically to text inputs.

Controlled Textareas

You'll learn how React textareas differ from HTML textareas and work just like controlled text inputs.

The HTML vs React Difference

In plain HTML, a <textarea> element uses its children to set the value:

<textarea>Some initial text here</textarea>

But React does things differently. In React, textareas use the value prop instead of children, making them work identically to <input type="text">.

The React Pattern

A controlled textarea follows the exact same pattern you learned for text inputs:

function CommentForm() {
  const [comment, setComment] = useState('');

  return (
    <textarea 
      value={comment}
      onChange={(e) => setComment(e.target.value)}
    />
  );
}

Notice:

  • The value prop (not children between tags) controls what appears
  • The onChange handler updates state with event.target.value
  • The textarea is self-closing or has empty children

Why This Design?

By treating textareas like inputs, React gives you a consistent API. Whether you're working with <input>, <textarea>, or (later) <select>, the controlled component pattern stays the same: value + onChange + useState.

This uniformity makes form handling predictable. You don't need to remember special cases—every text-based form element follows the same rules.

Key Takeaway: React textareas use the value prop instead of children, making them work identically to controlled text inputs with the same value + onChange + useState pattern.