Skip to content

Textarea

Collect multi-line text in a field that grows with its content, then scrolls.

import { Textarea } from '@youj/react'

Installation & usage

npm i @youj/react

For an app already set up with npx @youj/cli init, which installs the peers (@youj/core, @youj/motion, motion and Base UI) and wires the provider. New app? Start at Installation.

Use Textarea for comments, feedback, descriptions and other multi-line text. Use an Input for a single line. Wrap the textarea in an Input Group when you need a toolbar or send button inside its frame.

import { Field, FieldDescription, FieldLabel, Textarea } from '@youj/react'

export function ProjectDescription() {
  return (
    <Field>
      <FieldLabel>Description</FieldLabel>
      <Textarea name="description" placeholder="What does this project do?" />
      <FieldDescription>Shown on the project page and in search.</FieldDescription>
    </Field>
  )
}

It renders a real <textarea> through Base UI's field control, so inside a Field it's labeled, described, validated and made required exactly like an Input. rows, cols and wrap go to the element.

Reference

Propsvalue, defaultValue (2)

Props

Textarea props
PropType
valuestring–
defaultValuestring–

value and defaultValue take strings. Every other native textarea attribute passes through, including onChange, rows and maxLength.

MotionHover and focus · reduced motion

Motion

Motion tokens
MomentTokens
Hover and focusborder color, fill and the focus halo
duration.fastease.standard

140ms · cubic-bezier(0.2, 0, 0, 1)

140mscubic-bezier(0.2, 0, 0, 1)

Reduced motion

There is nothing to reduce: growing with its content is instant, and colors change on the fast token.

Reduced motion

The textarea doesn't animate. It grows line by line as you type, with or without reduced motion.

AccessibilityKeyboard, ARIA, focus

Accessibility

  • It's a native <textarea>: Enter adds a new line and Tab moves focus on.
  • Label it through a Field, or with aria-label when the context names it.
  • If you use maxLength, say so in the description. The browser stops accepting input silently, which reads as a broken keyboard.
  • Text is 16px on touch screens, so iOS doesn't zoom the page on focus.