Keyframery

Textarea

The focus ring closes in on a spring and the character count rolls.

See it as an AI agent does.

Resize preview. Focus the handle and use the left or right arrow keys. Hold Shift for larger steps.— px
Customize1 controls
Animation speed1×

Installation

npx shadcn@latest add @keyframery/textarea

This adds components/keyframery/textarea.tsx and its primitive to your project, and installs UI SDK. The motion tokens are added to your global CSS the first time you install a component.

Usage

import { Textarea } from "@/components/keyframery/textarea"

export default function Usage() {
  return <Textarea placeholder="Write a message" />
}

Examples

Grows as you type

autoResize makes it as tall as its text. Cap it with a max-h class.

Send with a shortcut

submitShortcut="mod+enter" runs onSubmit on ⌘ Enter or Ctrl Enter, for chat and comment boxes.

With a character count

Pair maxLength with a count so people see how much room is left.

Motion

MoveWhat you see
SpringThe focus ring closes in on a spring.
RollThe character count rolls.

Timing and springiness follow the motion style you set. To change how fast this textarea moves, pass speed:

<Textarea speed="fast">
  …
</Textarea>

"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.

Theming

Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.

VariableWhat it changesDefault
--textarea-faceField surface--background; --muted at 50% when read-only; --muted when disabled
--textarea-inkField text and placeholder--foreground; --muted-foreground at 70% for placeholder
--textarea-ringFocus ring and focused hairline--ring
--textarea-radiusField corners10px
--textarea-min-heightMinimum field height76px
--textarea-max-heightMaximum field height220px

API reference

Every part takes className and children. Parts from UI SDK also take render, to draw your own element, and a function of their state for className and style. Props not listed here are in the UI SDK textarea reference.

Textarea

Renders a <textarea>, and takes its props too.

Prop

Type

Keyboard

KeyWhat it does
EnterSends, when submitShortcut is "enter". Shift + Enter adds a line.
Mod + EnterSends, when submitShortcut is "mod+enter".

Accessibility

Keyboard, focus and screen-reader behaviour come from UI SDK and are not changed. More in Accessibility.

Swap the import

Already using UI SDK's textarea with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.

// Before
import { … } from "@ui-sdk/react/textarea"

// After: same parts, same props, now animated
import { … } from "@/components/keyframery/primitives/textarea"

Questions

How does the animated Textarea for UI SDK move?

Spring: The focus ring closes in on a spring. Roll: The character count rolls.

Do I need Motion or Framer Motion for the animated Textarea?

No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.

Can I keep my own styling and only take the motion?

Yes. Import from @/components/keyframery/primitives/textarea instead. It has the same parts and props as @ui-sdk/react/textarea and adds motion only.

What happens to the Textarea when someone turns on reduced motion?

Nothing moves. State changes happen at once, or with a short fade.

All components

On this page