October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Build a Plain-Text Editor Component in React

Use React’s built-in textarea for plain-text editing. Learn when to control it with state, when to use defaultValue, and how to label it accessibly.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a basic multiline text editor in React, use the built-in <textarea>. Choose a controlled textarea when React needs the text as the user types; choose defaultValue when the browser can own edits after the initial content is set. The examples below build a labeled plain-text editor, not a rich-text editor with formatting or collaborative editing.

Build a controlled React text editor

A controlled textarea gets its displayed text from React state. This is useful when other parts of the interface need the current text, such as a live character count or preview.

import { useState } from 'react';

export default function TextEditor() {
  const [text, setText] = useState('');

  return (
    <div>
      <label htmlFor="editor-text">Text</label>
      <textarea
        id="editor-text"
        value={text}
        onChange={(event) => setText(event.target.value)}
        rows={10}
        cols={50}
      />
      <p>Characters: {text.length}</p>
    </div>
  );
}

The onChange handler reads event.target.value and updates state synchronously. That keeps the state-backed value aligned with what the user just typed. Initialize state with a string and keep it a string for the textarea’s entire lifetime; do not change the same field from uncontrolled to controlled or the reverse.

Choose controlled or uncontrolled behavior

React describes its built-in <textarea> as a multiline text input. The choice is whether React should own the current value or whether the browser should handle ongoing edits after an initial value.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Editors Keys Avid Pro Tools Keyboard for Mac | Fully Backlit Mac Shortcut Keyboard | Genuine
  • Tailored for Mac: Specifically designed for Mac users, this Avid Pro Tools Backlit Keyboard aligns perfectly with your existing Mac ecosystem, ensuring seamless integration and optimal performance.
  • Backlit Keys for Enhanced Visibility: Work in any lighting environment with confidence. The gentle backlighting illuminates the keys so you can easily navigate your keyboard in low-light conditions without missing a beat.
  • Optimized for Pro Tools: Each key features a Pro Tools shortcut, icon, and text, with color-coded keys to streamline your editing process. You'll spend less time memorizing commands and more time creating.
  • Elegant and Durable Design: A sleek black finish not only complements your Mac's aesthetic but also includes keys that are crafted for longevity, able to withstand the rigors of intense editing sessions.
  • Plug-and-Play Convenience: The Avid Pro Tools Backlit Keyboard is ready to go right out of the box. No complicated setup or software installation required—just plug it into your Mac and elevate your editing workflow immediately.
Approach Set the text with Who owns edits? Use it when
Controlled value plus onChange React state Other UI needs the current text, or the app must respond to each edit.
Uncontrolled defaultValue The browser after initialization Only an initial value is needed and React does not need each keystroke.

Uncontrolled textarea with initial content

export default function NotesField() {
  return (
    <label htmlFor="notes">
      Notes
      <textarea id="notes" defaultValue="Start writing here." rows={8} />
    </label>
  );
}

Use defaultValue for initial text; React does not support setting the initial textarea text by placing JSX children between the opening and closing <textarea> tags. If you need React to track later edits, use the controlled pattern instead.

Label the field and size it for the task

Associate a visible label with the textarea. You can nest the field inside a <label>, or connect a separate <label htmlFor> to the textarea’s matching id, as in the controlled example. React notes that screen readers announce the label caption when the field receives focus. Set rows and, where appropriate, cols to provide a useful starting size; CSS can handle the visual layout.

Rank #2
Blackmagic Design USB Davinci Resolve Editor Keyboard
  • Designed for professional editors who need to work faster and turn over quickly
  • Designed for DaVinci Resolve 16
  • Integrated search wheel integrated directly into the keyboard

When a textarea is not enough

A textarea handles plain text. If the requirement is formatted content, browser editing of rendered content is possible with contentEditable, but it is not a drop-in replacement for a textarea. React warns that its normal rendering of children does not work as usual on an editable element: after a user edits that content, React cannot update it normally.

The suppressContentEditableWarning prop only hides React’s warning when a library manages editable content manually. It does not provide synchronization, cursor or selection handling, security, or accessibility behavior. React also warns that inserting untrusted HTML with dangerouslySetInnerHTML can expose an application to cross-site scripting (XSS). A formatted or collaborative editor therefore needs additional design and implementation beyond this plain-text component.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Mathematical Keyboard — Type Math Faster on Your Computer
  • Type Math Symbols Directly: Insert math, Greek, and scientific characters from the symbols printed on the keys; avoid searching symbol menus, memorizing Alt codes, or repeatedly copying and pasting characters
  • Works in the Apps You Already Use: Inserts standard text, not images, for symbols and inline expressions in Word, Google Docs, notes, email, presentations, Notion, and compatible browser fields
  • Normal Keyboard With Math Layers: Use the compact 78-key keyboard for everyday typing; access 55 printed math symbols with Ctrl+Alt and Ctrl+Alt+Shift on Windows, or Control+Option combinations on Mac
  • Windows and Mac Setup: Supports Windows 10 and 11 and macOS 15 or later; normal typing works immediately, while a one-time companion app setup enables the printed math layers
  • Compact Wireless Hardware: 78 quiet low-profile keys; connect by Bluetooth or 2.4 GHz with the included USB-A receiver; rechargeable battery; USB-C is for charging, not wired keyboard use; one connection at a time
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep typing responsive

Updating controlled state on every keystroke is necessary to keep a controlled textarea current. It can also cause related UI to render on each edit. Keep the state and components focused, and avoid changing keys or component structure in a way that remounts the textarea while someone is typing; remounting can disrupt the editing experience. Do not defer the state update that supplies the textarea’s value.

Quick Recap

Bestseller No. 2
Blackmagic Design USB Davinci Resolve Editor Keyboard
Blackmagic Design USB Davinci Resolve Editor Keyboard
Designed for professional editors who need to work faster and turn over quickly; Designed for DaVinci Resolve 16
$669.00
Rank #4
TourBox NEO - Editing Controller, Desktop Creative Multi-Control, Wired
  • A Better Way to Create. —Your creative workflow shouldn't be split between keyboard, mouse, and software panels. TourBox brings essential controls together, so fewer interruptions stand between your ideas and your work
  • Go Beyond Shortcuts. —TourBox gives every creative application its own control system. Press, turn, scroll, and navigate with dedicated controls instead of relying on a flat keyboard and mouse for every task
  • Streamline Every Workflow. —Whether you create in Lightroom, Premiere Pro, Photoshop or more, NEO gives you a complete way to start with TourBox, NEO gives you a complete way to start with TourBox. Elevate your experience across digital drawing, color grading, photo editing, and video editing
  • More Controls, More Possibilities. —With 14 dedicated controls included additional D-Pad, Dial, and buttons, NEO gives you the core TourBox experience, with more control than Lite
  • More Control. Less Space. —NEO brings frequently used control, ergonomic design, and intelligent creative software together in one compact system. More of the actions you use most stay within reach, while the same physical control logic adapts to different applications and creative tasks

React references

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.