Textarea
A multiline text field that grows to a maximum height, then scrolls.
npx @swipeui/cli add textareaWhen to use it
- Notes, comments, reviews, bios and messages that may run several lines.
- Feedback forms where people write a paragraph.
- Any text entry where the box should grow as people type, up to a limit.
- Fields that need the same label, helper and error as Text field.
When not to use it
- Short single-line answers. Use Text field.
- Rich text with formatting. Use a dedicated editor.
- Chat inputs pinned to the keyboard; build a composer with a send button.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add textarea- Adds
components/swipeui/ui/textarea.tsxand 13 shared helpers. - Installs react-native-reanimated, react-native-worklets, uniwind, clsx, tailwind-merge, expo-haptics, class-variance-authority, react-native-svg. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { Textarea } from '@/components/swipeui/ui/textarea';
<Textarea label="Notes" maxHeight={240} />;Examples
Use the variant and appearance controls in the live specimen to compare the documented states. The application owns validation, operation results and persistence.
API reference
TextareaProps
| Prop | Type | Default | Description |
|---|---|---|---|
label? | | — | Visible label, or inherit an enclosing Field. |
helper? | | — | Instructions under the field; an error or success message replaces it. |
error? | | — | Validation message: a destructive ring, an alert glyph, one shake and an error haptic. |
success? | | — | Confirmation under the field, such as "Username available", in the success colour. |
status? | | |
|
required? | | | Required; "Required" is spoken, and |
requiredIndicator? | | | How a required label is marked: a muted asterisk, the word, or nothing. |
optionalIndicator? | | | Show a muted "Optional" after the label. |
disabled? | | | Disable editing and accessory actions. |
disabledStyle? | | |
|
appearance? | | | The surface: |
size? | | | Height: |
shape? | | |
|
labelPlacement? | | |
|
focusRing? | | | The focus indicator: a primary ring with a soft halo, the ring alone, or none. |
messageMorph? | | | How a changed message arrives: rises in, letter by letter, or at once. |
reserveMessageSpace? | | | Keep one line of room under the field so forms don't move as messages appear. |
value? | | — | Controlled text. |
defaultValue? | | | Initial uncontrolled text. |
onValueChange? | | — | Reports changed text, including clearing and undo. |
onChangeText? | | — | Native-compatible text callback, in addition to onValueChange. |
displayValue? | | — | Decorative rendering for an unfocused value; the native text remains the accessible/editable source. |
prefix? | | — | Decorative prefix or an accessible accessory, drawn first. |
suffix? | | — | Accessible trailing accessory, drawn last. |
leadingIcon? | | — | A leading icon: a node, or a function given the state colour and size. It turns primary while focused. |
trailingIcon? | | — | A trailing icon: a node, or a function given the state colour and size. |
clearable? | | | 1.x switch: |
clearButton? | | | When a "Clear text" button shows. |
undoClear? | | | After clearing, the button becomes "Undo clear" for a moment. Phones have no ⌘Z. |
undoClearWindow? | | | How long undo stays, in milliseconds. |
counter? | | | A rolling character counter under the field, using |
tintCaret? | | | Caret and selection in the primary colour. |
iconTint? | | | The leading icon turns primary while focused ( |
shakeOnError? | | | Shake once for each new error. Reduce Motion keeps it still. |
messages? | | | Built-in strings, for translation. |
nextRef? | | — | Ref focused when Return is pressed; otherwise a single-line field dismisses. |
haptics? | | | All feedback, or each part: |
motion? | | | Ring, label and message motion. |
className? | | — | Classes on the outer field. |
controlClassName? | | — | Classes on the field surface. |
inputClassName? | | — | Classes on the editable text. |
style? | | — | Outer field style. |
inputStyle? | | — | Native editable text style. |
minHeight? | | | Minimum editable height in points. |
maxHeight? | | | Maximum height before native scrolling takes over. |
Native view/input props not listed here pass through where the exported TypeScript type allows them.
Composition and behavior
- A multiline Text field with minHeight (88) and maxHeight (240).
- Supports label, helper, error and required like Text field.
Textarea settings
The multiline editor grows to maxHeight and keeps native scrolling available while typing, allowing the platform to follow the caret without forcing selection to the end. You can still scroll back to edit earlier lines.
| Prop | Does | Default |
|---|---|---|
| minHeight | Initial editable height | 88 |
| maxHeight | Height before internal scrolling | 240 |
| scrollEnabled | Allow the editor to follow typing and scroll | true |
Behavior and gestures
- Starts 88 points tall and grows with each new line.
- After 240 points (maxHeight), it stops growing and scrolls inside.
- Return adds a new line instead of closing the keyboard.
- Everything else works like Text field: focus colour, helper, error and disabled.
Accessibility
- Labelled like Text field, with helper and error read as the hint.
- Growing never limits font scaling, so large text stays fully visible.
- Scrolling inside is only needed after the maximum height.
Motion
- Uses the
pressmotion role, so it follows your app's feel. Passmotionto tune this one instance. - Height follows content without animation, so typing feels immediate.
Performance
- Height is measured from native content size; no extra layout passes.
Notes for AI
- Set minHeight and maxHeight to fit your layout.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.