Vibary.ai
← Vibe Coding

Textarea Autogrow

The field takes one line-height more as the text wraps, easing into it rather than snapping.

formscalmminimalinteraction · finite · intermediate · ~0.2s
Interactive · click to play
Variant

The animated component in this preview is rendered from the canonical file shown here. The surrounding demo shell only provides context and is not part of the copied code.

220 lines · react + motion only
import {
  useEffect,
  useId,
  useLayoutEffect,
  useRef,
  useState,
} from "react";
import { motion, useReducedMotion } from "motion/react";

About this pattern

The height is read from a hidden mirror holding the same text in the same font at the same width, which is why the growth is correct on the frame the wrap happens rather than one frame late. Height is one of the few properties worth animating outright, since the motion genuinely is a size change — but it runs as a short eased tween and never a spring: a field that springs past its own height flashes a clipped line of the user's own writing. Past the row cap it stops growing and scrolls, and the hint says so.

Comment composerChat inputFeedback formNote field

Where it shows up

Screens we drew to show where this motion usually sits. Illustrations, not captures of any product.

  • Dana Whitfield
    Priya Raman
    Ops standup
    Marcus Bell
    Design sync
    Nils Bergström
    Dana Whitfieldonline
    Morning — did the venue confirm?
    They did, contract came back signed.10:14
    Are we still on for Thursday?
    Yes — booked the room for 2pm.10:14
    Perfect. I'll bring the printouts.
    See you then.10:14
    Message
    Chat thread

    A field that grows to a cap and then scrolls, without the caret jumping.

Related patterns