Primitives
Animated Number Avatar Badge Button Button Group Toggle Toggle Group Checkbox Chip Countdown Divider Fab Grid Icon Image Input Search Input Textarea Label Loader Marquee Masked Input Message Bubble Notification Banner Offline Banner Progress Progress Ring Radio Group Range Slider Rating Separator Skeleton Slider Stack Stepper Switch Text Theme Toggle Ticker Typing IndicatorComposed
Accordion Achievement Badge Action Bar Action Sheet Action Swap Activity Rings Add to Cart Button Address Card Agenda List Alert Amount Keypad Animated Icons App Bar Audio Message Audio Recorder Autocomplete Avatar Group Balance Display Bar List Barcode Before After Biometric Gate Bloom Menu Bottom Sheet Paywall Sheet Side Sheet Breadcrumb Calendar Calendar Strip Card Carousel Cart Item Character Charts Chat Composer Chat List Item Choice Card Circle Reveal Coach Marks Collapsible Collapsible Header Color Picker Combobox Command Palette Comment Thread Confetti Consent Sheet Context Menu Copy Field Country Picker Coupon Input Currency Input Data Table Date Range Picker Day Schedule Dialog Dock Donut Chart Drawer Driver Card Dropdown Menu Drum Picker Emoji Picker Empty State Error State Event Card Expandable Control Fader Feature Gate File Picker Filter Bar Follow Button Form Gauge Glass Glass Cluster Glass Dock Morph Glass Fab Morph Glass Lab Glass Orb Glass Search Morph Glass Sheet Edge Gradient Button Headline New Heatmap Image Cropper Image Viewer Kanban Card Keyboard Avoiding Keyboard Toolbar Leaderboard Level Progress Lightbox Like Button Line Chart List Reorderable List Swipeable Row Location Card Location Search Map Sheet Map View Markdown View Media Controls Media Picker Media Tile Mention Input Meter Bar Mini Player Mood Slider Morphing Modal Multi Select Navigation Rail Notification Item Number Input Onboarding Pager Order Card Order Summary OTP Input Pagination Paper Clip New Parallax Header Pass Card Password Strength Payment Button Payment Card Payment Method Permission Primer Phone Input PIN Pad Polaroid New Poll Popover Post Card Postage Stamp New Price Tag Pricing Table Product Card Product Gallery Profile Header Promo Banner Prompt Input Property Card Pull To Refresh QR Code Quick Actions Quick Replies Rating Summary Reaction Picker Resend Timer Review Card Review Prompt Ride Option Save Button Scan Frame Scroll Spy Tabs Seat Map Section Header Section Index Segmented Control Select Share Button Share Sheet Shutter Button Signature Pad Slide to Confirm Slot Picker Smart Banner Social Login Button Sparkline Splash Screen Split Button Stat Card Stateful Button Status Dot Step Flow Steps Sticker New Stopwatch Stories Progress Stories Viewer Story Ring Streak Counter Streaming Text Success Seal Swipe Deck Tabs Tag Input Tape New Text Reveal Thinking Indicator Time Picker Timeline Timer Ring Tip Selector Toast Toolbar Tooltip Track Row Transaction Row Trip Progress Variant Picker Video Controls Waveform Weather Card Weekday Picker Zoom TransitionScreens
Account Switcher Biometric Setup Delete Account Forgot Password Grow Auth Login Login — Dark Stage Login — Dense Work Login — Editorial Login — Illustrated Login — Minimal Ink Login — Social Login — Video Loop Food Onboarding Onboarding Onboarding Dark Objects Onboarding Editorial Onboarding Illustrated Onboarding Personalize Onboarding Photo Carousel OTP Verification Passkey — Create Password Reset Permission — Notifications Phone Verification Onboarding Quiz Session Devices Signup Sign-up Chat Sign-up Photo Sheet Social Auth Split Auth Verify Identity Welcome AI Chat AI Assistant Channels List Chat Info Chat List Chat Media Chat Thread Create Group Group Info Message Requests New Message Kept Messages Accessibility Activity Log Appearance Authenticator Blocked Accounts Export Your Data Downloads Edit Profile Edit Profile — Rows Emergency Call Empty States Set Error State Send Feedback Device Locator Help Center Home — Bento Home — Dark Home — Editorial Home Feed Invite Friends Language & Region Linked Accounts Not Found (404) Notification Settings Notifications Password Vault Paywall Paywall — Comparison Paywall — Dark Stage Paywall — Editorial Paywall — Photo Paywall — Trial Timeline Privacy Profile Profile — Gamified Profile — Minimal Profile — Photo Hero QR Scanner Report Issue Saved Items Phone Time Search Search — Command Palette Search — Visual Account Health Settings Settings — Dark Device Settings — Search Storage & Data Terms & Privacy Dating Chat Dating Filters Profile Discover Its A Match Into You Matches Profile Detail Profile Editor Courier Matching Delivery History Delivery Support Package Schedule Parcel Tracking Proof Of Delivery Quick Aisle Quick Home Send Package Substitutions Add Payment Address Book Cart Categories Checkout Checkout — Steps Checkout Success Delivery Filters & Sort Flash Sale Gift Cards Loyalty Points Order Cancel Order Detail Orders Pay Later Checkout Payment Methods Product Detail Product Detail — Hero Product Grid Product Reviews Promo Codes Recently Viewed Return Items Search Results Shop Assistant Store Home Tip & Rate Courier Order Tracking Wishlist Write a Review Event Checkin Event Hero Events Discover My Tickets Seat Selection Ticket Checkout Add Card Bank Accounts Dashboard — Bento Bill Pay Budgets Card Details Crypto Portfolio Finance Dashboard Dashboard — Dark Exchange Currency Expense List Invoice Detail Manage Cards Plan Management Savings Goals Send Money Spending Analytics Split Bill Subscriptions Token Detail Token Swap Transactions Wallet Home Wallet Movers Courier Tracking Food Cart Food Home Food Orders Grocery List Recipe Detail Restaurant — Dark Restaurant Detail Activity Rings Fitness Home Habit Quest Habit Tracker Meal Planner Med Store Meditation Player Mood Check-in Nutrition Home Period Tracker Prior Auth Prior Auth Cases Quest Complete Run Tracking Rx Scan Sleep Tracker Telehealth Booking Walk Map Water Tracker Workout Complete Workout Detail Workout Session Applications Apply Company Interview Schedule Job Detail Job Feed Resume Saved Jobs Create Listing Item Chat Listing Detail Make Offer Market Checkout Market Home Market Search My Listings Offers Inbox Seller Profile Audiobook Player Camera Gallery Albums Game Store Mini Player Music Player Photo Editor Photo Gallery Playlist Detail Podcast Player Clips Feed Serene Home Sound Mixer Stories Video Call Video Player Article Reader Course Detail Event Detail Memory Onboarding Icon Lab Leaderboard Lesson Player Match Detail News Editorial News Home Plant Care Prediction Live Prediction Welcome Smart Home Standings Ticket Wallet Topics Follow Weather Detail Add Task Sheet Alarm Clock Calendar Day Calendar Month Doc Scanner File Manager Focus Timer Journal Kanban Board Mail Inbox Mail Thread Note Editor Notes List Reminders Task List Time Blocks Agent Profile Compare Homes Mortgage Calculator Property Detail Rental Application Saved Homes Schedule Tour Search List Search Map Complete Destination Driver Arriving Ev Charging History Home In Trip Matching Options Parking Receipt Safety Schedule Scooter Unlock Booking Confirmed Booking Review Booking Slots My Bookings Pro On The Way Provider Detail Provider List Rate Service Services Home Arc Create Arc Detail Arc Onboarding Avatar Creator Comments Sheet Create Post Explore Grid Followers List Hashtag Feed Mentions Post Detail Post Hero Social Profile Boarding Pass Booking Confirm Car Rental Trip Discover Flight Live Flight Preferences Flight Results Flight Search Hotel Detail Live Transit Trip — Map Day Trip — Rideshare Request Seat Select Travel Home Trip Itinerary Trip OnboardingNothing matches — try another word.
Textarea
Multiline text field that can grow as you type and show a character count. Focus highlights the field, an error gives it a single nudge, and the count turns red at the limit.
Preview
import * as React from "react";
import { forwardRef } from "react";
import { TextInput, View, Text, type TextInputProps, type NativeSyntheticEvent, type TextInputContentSizeChangeEventData, type TextInputKeyPressEventData, } from "react-native";
import Animated, {
Easing,
useSharedValue,
useAnimatedStyle,
withSequence,
withSpring,
withTiming,
interpolateColor,
} from "react-native-reanimated";
import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
import { cn, ease, spring, timing, useHaptic, useReducedMotion, useTheme, AnimatedTextInput } from "@lumioui/core";
import { Glass } from "../glass";
/** Flicker for "can't" — one 4pt kick released into spring.shake (§5 rule 4). */
const ERROR_KICK = 4;
/** Focus light — a 1pt lit top edge, brightest over the middle of the field
* and fading at the corners: light marks where you write. */
const EDGE_ALPHA = 0.9;
/** The count starts swapping in place once this share of maxLength is used. */
const COUNT_NEAR = 0.9;
/** A count digit's directional travel as it swaps. */
const COUNT_TRAVEL = 4;
/** Refused keystroke at the limit: the count dips to this, then recovers. */
const FLICKER_DIP = 0.6;
const IGNITE = { ...timing.fast, easing: Easing.bezier(...ease.out) };
const useGradientId = () => React.useId().replace(/[^a-zA-Z0-9]/g, "");
export interface TextareaProps extends Omit<TextInputProps, "className" | "multiline"> {
/** Visible label above the field. */
label?: string;
/** Helper text below the field. */
helper?: string;
/** Error message — turns the field red. */
error?: string;
/** Minimum height in points. Default 96. */
minHeight?: number;
/** Grow with content. */
autoGrow?: boolean;
/** Show a live character count under the field ("n" or "n/max" with maxLength). */
showCount?: boolean;
/** NativeWind classes for the input. */
className?: string;
/** Glass field — rounded material instead of the flat fill. */
glass?: boolean;
/** Classes for the outer wrapper. */
containerClassName?: string;
multiline?: boolean;
}
/**
* Textarea — multiline Input with minHeight and optional auto-grow.
* Focus tints the border and lights a 1pt top edge over 160ms. An arriving
* error flickers the field once (4pt kick, warning haptic). Near maxLength
* the count swaps in place with each keystroke; a keystroke refused at the
* limit flickers the count.
*/
export const Textarea = forwardRef<React.ElementRef<typeof TextInput>, TextareaProps>(
function Textarea(
{
label,
helper,
error,
minHeight = 96,
autoGrow = false,
showCount = false,
className,
containerClassName,
glass = false,
multiline = true,
onContentSizeChange,
onChangeText,
value,
defaultValue,
maxLength,
editable = true,
onFocus,
onBlur,
onKeyPress,
style,
...props
},
ref
) {
const { colors } = useTheme();
const reduceMotion = useReducedMotion();
const haptic = useHaptic();
const edgeId = useGradientId();
const describedBy = error ?? helper;
// Built-in label gets a stable nativeID so the field can point back at
// it via accessibilityLabelledBy / aria-labelledby (Input parity).
const autoId = React.useId();
const labelId = `${autoId}-label`;
// Character count tracks typing; controlled `value` changes resync it.
const [textLen, setTextLen] = React.useState(() => (value ?? defaultValue ?? "").length);
// Auto-grow animates instead of jumping — the field eases taller.
const contentHeight = useSharedValue(minHeight);
// Error shake — same craft as Input.
const shake = useSharedValue(0);
/** Focus progression — drives the border color glide. */
const focusT = useSharedValue(0);
/** Read-only dim: 1 editable, 0.5 read-only — crossfaded, never snapped. */
const editT = useSharedValue(editable ? 1 : 0.5);
React.useEffect(() => {
editT.value = reduceMotion ? (editable ? 1 : 0.5) : withTiming(editable ? 1 : 0.5, timing.normal);
}, [editable, reduceMotion, editT]);
/** Error/helper text entrance: 0 hidden → 1 visible. */
const msgT = useSharedValue(error || helper ? 1 : 0);
const hadError = React.useRef(!!error);
React.useEffect(() => {
if (error && !hadError.current) {
haptic.warning();
if (!reduceMotion) {
// One flicker: a small kick released into the flicker spring.
shake.value = -ERROR_KICK;
shake.value = withSpring(0, spring.shake);
}
hadError.current = true;
} else if (!error) {
hadError.current = false;
}
const target = error || helper ? 1 : 0;
// timing.fast (150ms): message arrives quick enough to not flash.
msgT.value = reduceMotion ? target : withTiming(target, timing.fast);
// Mount-time errors arrive with the field; only a new error flickers.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [error, helper, reduceMotion, shake, msgT]);
const shakeStyle = useAnimatedStyle(() => ({
transform: [{ translateX: shake.value }],
}));
const heightStyle = useAnimatedStyle(() =>
autoGrow ? { height: Math.max(minHeight, contentHeight.value) } : {}
);
// Border color glides input → ring on focus; error wins outright.
const borderStyle = useAnimatedStyle(() => ({
opacity: editT.value,
borderColor: error
? colors.destructive
: interpolateColor(focusT.value, [0, 1], [colors.input, colors.ring]),
}));
// Focus light — the lit top edge brightens with focus (not on errors:
// the red border carries that state alone).
const edgeStyle = useAnimatedStyle(() => ({
opacity: error ? 0 : focusT.value,
}));
// Count: swaps in place near the limit, flickers on a refused keystroke.
const countIn = useSharedValue(1);
const countMove = useSharedValue(0);
const prevLen = React.useRef(textLen);
React.useEffect(() => {
const prev = prevLen.current;
prevLen.current = textLen;
if (maxLength == null || prev === textLen || textLen < maxLength * COUNT_NEAR) return;
// The outgoing figure is replaced by an incoming one that ignites,
// travelling a few points in the direction the count moved.
countIn.value = 0.4;
countIn.value = withTiming(1, IGNITE);
if (reduceMotion) return;
countMove.value = textLen > prev ? COUNT_TRAVEL : -COUNT_TRAVEL;
countMove.value = withSpring(0, spring.swap);
}, [textLen, maxLength, reduceMotion, countIn, countMove]);
const countStyle = useAnimatedStyle(() => ({
opacity: countIn.value,
transform: [{ translateY: countMove.value }],
}));
const handleKeyPress = (e: NativeSyntheticEvent<TextInputKeyPressEventData>) => {
// A character refused at the limit flickers the count once.
if (maxLength != null && textLen >= maxLength && e.nativeEvent.key !== "Backspace") {
haptic.warning();
countIn.value = withSequence(withTiming(FLICKER_DIP, timing.instant), withTiming(1, timing.fast));
if (!reduceMotion) {
countMove.value = ERROR_KICK;
countMove.value = withSpring(0, spring.shake);
}
}
onKeyPress?.(e);
};
const msgStyle = useAnimatedStyle(() => ({
opacity: msgT.value,
transform: [{ translateY: reduceMotion ? 0 : (1 - msgT.value) * -4 }],
}));
const handleContentSizeChange = (
e: NativeSyntheticEvent<TextInputContentSizeChangeEventData>
) => {
if (autoGrow) {
const next = e.nativeEvent.contentSize.height;
// Reduced motion: snap to the measured height instead of easing.
// timing.fast (150ms) tracks typing without jumping.
if (reduceMotion) contentHeight.value = next;
else contentHeight.value = withTiming(next, timing.fast);
}
onContentSizeChange?.(e);
};
const handleChangeText = (text: string) => {
setTextLen(text.length);
onChangeText?.(text);
};
// Controlled `value` changes (set externally, e.g. cleared) resync the count.
React.useEffect(() => {
if (typeof value === "string") setTextLen(value.length);
}, [value]);
return (
<View className={cn("gap-1.5", containerClassName)}>
{label ? (
<Text
nativeID={labelId}
className="text-sm font-medium text-foreground"
accessibilityRole="text"
>
{label}
</Text>
) : null}
<Animated.View style={shakeStyle}>
{glass ? (
<Glass
effect="regular"
sheen={0.4}
className="absolute inset-0"
style={{ borderRadius: 16 }}
pointerEvents="none"
/>
) : null}
<AnimatedTextInput
ref={ref}
editable={editable}
multiline={multiline}
onFocus={(e) => {
focusT.value = reduceMotion ? 1 : withTiming(1, timing.fast);
onFocus?.(e);
}}
onBlur={(e) => {
focusT.value = reduceMotion ? 0 : withTiming(0, timing.fast);
onBlur?.(e);
}}
onContentSizeChange={handleContentSizeChange}
onChangeText={handleChangeText}
onKeyPress={handleKeyPress}
value={value}
defaultValue={defaultValue}
maxLength={maxLength}
className={cn(
// Constant border-[1.5px] — width never flickers; the color is
// animated in borderStyle, not swapped via classes.
glass
? "min-h-[96px] rounded-2xl border-[1.5px] border-transparent bg-transparent px-3.5 py-3 text-base text-foreground"
: "min-h-[96px] rounded-xl border-[1.5px] border-transparent bg-background px-3.5 py-3 text-base text-foreground",
"placeholder:text-muted-foreground",
className
)}
style={[
{
minHeight,
textAlignVertical: "top",
},
heightStyle,
borderStyle,
style,
]}
accessibilityLabel={label ?? props.accessibilityLabel}
accessibilityLabelledBy={label ? labelId : undefined}
aria-labelledby={label ? labelId : undefined}
accessibilityHint={describedBy}
accessibilityState={{ disabled: !editable }}
// accessibilityState isn't forwarded to the DOM on web — mirror
// the error with an explicit aria-invalid like Checkbox does.
aria-invalid={!!error}
{...props}
/>
{/* Focus light — a 1pt lit top edge just inside the border, fading
toward the corners. Replaces an outer halo: light marks where
you write instead of a glow ring around the chrome. */}
<Animated.View
pointerEvents="none"
accessibilityElementsHidden
importantForAccessibility="no-hide-descendants"
style={[{ position: "absolute", top: 1, left: 12, right: 12, height: 1 }, edgeStyle]}
>
<Svg width="100%" height="100%">
<Defs>
<LinearGradient id={edgeId} x1="0" y1="0" x2="1" y2="0">
<Stop offset={0} stopColor={colors.ring} stopOpacity={0} />
<Stop offset={0.5} stopColor={colors.ring} stopOpacity={EDGE_ALPHA} />
<Stop offset={1} stopColor={colors.ring} stopOpacity={0} />
</LinearGradient>
</Defs>
<Rect x="0" y="0" width="100%" height="100%" fill={`url(#${edgeId})`} />
</Svg>
</Animated.View>
</Animated.View>
{error || helper || showCount ? (
<Animated.View
style={error || helper ? msgStyle : undefined}
className="flex-row items-start justify-between gap-2"
>
{error ? (
<Text
className="flex-1 text-sm text-destructive"
accessibilityLiveRegion="polite"
accessibilityRole="alert"
>
{error}
</Text>
) : helper ? (
<Text className="flex-1 text-sm text-muted-foreground">{helper}</Text>
) : (
<View className="flex-1" />
)}
{showCount ? (
<Animated.Text
style={countStyle}
className={cn(
"text-sm",
maxLength != null && textLen >= maxLength
? "text-destructive"
: "text-muted-foreground"
)}
accessibilityLabel={
maxLength != null
? `${textLen} of ${maxLength} characters`
: `${textLen} characters`
}
>
{maxLength != null ? `${textLen}/${maxLength}` : textLen}
</Animated.Text>
) : null}
</Animated.View>
) : null}
</View>
);
}
);
Textarea.displayName = "Textarea"; import { Textarea } from "@/components/ui/textarea/textarea";
export function Example() {
return (
<Textarea />
);
} Installation
Install the dependencies
npx expo install react-native-reanimated react-native-svgAdd the components it builds on
Copy the source from the Code tab into your project
components/ui/textarea/textarea.tsxcomponents/ui/textarea/index.tsUpdate the import paths to match your project setup.
Usage
import { Textarea } from "@/components/ui/textarea/textarea"; <Textarea /> Examples
A support "Report a problem" form, ink only.
import * as React from "react";
import { View } from "react-native";
import { Textarea } from "../textarea";
import { Button } from "../../button/button";
import { Icon } from "../../icon/icon";
import { Text } from "../../text/text";
const MIN = 30;
/** Stand-in for the network round trip, so the send can be seen. */
const SEND_MS = 900;
/** TextareaError — a support "Report a problem" form, ink only. It opens on
* a rejected submit; typing clears the error, and sending a description
* that's still too short flickers the field again and says how far off.
* A good report sends in place: the button carries the light while it
* sends, then becomes "Sent" and the field dims to read-only — the form
* keeps the evidence instead of a helper line announcing it. */
export function TextareaError() {
const [text, setText] = React.useState("App crashes on upload");
const [tried, setTried] = React.useState(true);
const [sent, setSent] = React.useState(false);
const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);
React.useEffect(() => () => {
if (timer.current) clearTimeout(timer.current);
}, []);
const short = text.trim().length < MIN;
const error = tried && short ? `Add a little more detail, ${MIN - text.trim().length} more characters` : undefined;
return (
<View className="w-full gap-5 rounded-3xl bg-card p-5">
<View className="gap-1">
<Text className="text-2xl font-bold tracking-tight">Report a problem</Text>
<Text variant="muted">Harbor for iOS 4.12 · iPhone 15</Text>
</View>
<Textarea
label="What happened?"
placeholder="What were you doing, and what did you expect?"
value={text}
onChangeText={(t) => {
setText(t);
setTried(false);
}}
editable={!sent}
error={error}
helper="Steps to reproduce help the most."
maxLength={500}
showCount
minHeight={120}
autoGrow
/>
<Button
size="lg"
className="w-full"
icon={sent ? <Icon name="check" size="sm" color="primaryForeground" strokeWidth={3} /> : undefined}
onPress={() => {
if (sent) return;
setTried(true);
if (short) return;
return new Promise<void>((resolve) => {
timer.current = setTimeout(() => {
setSent(true);
resolve();
}, SEND_MS);
});
}}
>
{sent ? "Sent · we reply within a day" : "Send report"}
</Button>
</View>
);
} The caption step of a photo post: the glass field rides over the photo being shared (the one place glass is earned), grows with the caption, and Share wakes up once there's text.
import * as React from "react";
import { Image, StyleSheet, View } from "react-native";
import { Textarea } from "../textarea";
import { Button } from "../../button/button";
const PHOTO =
"https://images.unsplash.com/photo-1513735492246-483525079686?w=800&h=1000&fit=crop&q=70&auto=format";
/** TextareaGlass — the caption step of a photo post: the glass field rides
* over the photo being shared (the one place glass is earned), grows with
* the caption, and Share wakes up once there's text. */
export function TextareaGlass() {
const [caption, setCaption] = React.useState("");
return (
<View className="relative h-[460px] w-full overflow-hidden rounded-3xl bg-muted">
<Image source={{ uri: PHOTO }} style={StyleSheet.absoluteFill} resizeMode="cover" accessibilityIgnoresInvertColors />
<View className="absolute inset-x-4 bottom-5 gap-3">
<Textarea
glass
value={caption}
onChangeText={setCaption}
placeholder="Write a caption…"
minHeight={88}
autoGrow
maxLength={220}
accessibilityLabel="Caption"
/>
<Button size="lg" className="w-full" disabled={caption.trim().length === 0}>
Share
</Button>
</View>
</View>
);
} An evening journal entry in green.
import * as React from "react";
import { Pressable, View, type LayoutChangeEvent } from "react-native";
import Animated, { Easing, useAnimatedStyle, useSharedValue, withDelay, withSpring, withTiming } from "react-native-reanimated";
import { Accent, Sheen, ease, spring, timing, useHaptic, useReducedMotion, useTheme } from "@lumioui/core";
import { Textarea } from "../textarea";
import { Button } from "../../button/button";
import { Chip } from "../../chip/chip";
import { Icon } from "../../icon/icon";
import { Text } from "../../text/text";
const PROMPTS = ["What gave you energy?", "One thing you're grateful for", "What would you do differently?"];
/** The saved entry holds in place before it folds (act, hold, resolve). */
const SAVE_HOLD = 650;
/** Height of the folded "Saved" row. */
const SAVED_ROW = 64;
const DIM = { ...timing.recede, easing: Easing.bezier(...ease.in) };
const IGNITE = { ...timing.fast, easing: Easing.bezier(...ease.out) };
const clock = () => new Date().toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" });
/** TextareaNote — an evening journal entry in green. The field auto-grows
* as you write; tapping a prompt chip appends it as a new line. Save
* stamps the entry where it is: one sheen crosses the card, the words hold
* 650ms, then the card folds on the surface spring into a "Saved" row that
* stays — tap it to keep writing. */
export function TextareaNote() {
const haptic = useHaptic();
const reduce = useReducedMotion();
const { colors } = useTheme();
const [entry, setEntry] = React.useState(
"Walked the long way home along the canal. Finished the first draft of the grant before lunch."
);
const [phase, setPhase] = React.useState<"writing" | "holding" | "saved">("writing");
const [savedAt, setSavedAt] = React.useState("");
const [sheen, setSheen] = React.useState(0);
const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);
React.useEffect(() => () => {
if (timer.current) clearTimeout(timer.current);
}, []);
const full = React.useRef(0);
const height = useSharedValue(-1);
const body = useSharedValue(1);
const row = useSharedValue(0);
const cardStyle = useAnimatedStyle(() => (height.value < 0 ? {} : { height: height.value }));
const bodyStyle = useAnimatedStyle(() => ({ opacity: body.value }));
const rowStyle = useAnimatedStyle(() => ({ opacity: row.value }));
const fold = (open: boolean) => {
const to = open ? full.current : SAVED_ROW;
height.value = height.value < 0 ? full.current : height.value;
height.value = reduce ? withTiming(to, timing.normal) : withSpring(to, spring.surface);
if (open) {
row.value = withTiming(0, DIM);
body.value = withDelay(timing.recede.duration, withTiming(1, IGNITE));
} else {
body.value = withTiming(0, DIM);
row.value = withDelay(timing.recede.duration, withTiming(1, IGNITE));
}
};
const save = () => {
haptic.success();
setSheen((n) => n + 1);
setPhase("holding");
timer.current = setTimeout(() => {
setSavedAt(clock());
setPhase("saved");
fold(false);
}, SAVE_HOLD);
};
const reopen = () => {
haptic.light();
setPhase("writing");
fold(true);
// Once open, the card hugs its content again so the field can keep growing.
if (timer.current) clearTimeout(timer.current);
timer.current = setTimeout(() => {
height.value = -1;
}, timing.slow.duration);
};
const saved = phase === "saved";
return (
<Accent color="green" className="w-full">
<View className="w-full gap-5">
<View className="gap-1 px-1">
<Text variant="muted">Tuesday, October 7</Text>
<Text className="text-3xl font-bold tracking-tight">How was today?</Text>
</View>
<Animated.View className="overflow-hidden rounded-3xl bg-card" style={cardStyle}>
<Animated.View
className="gap-4 p-5"
style={bodyStyle}
pointerEvents={saved ? "none" : "auto"}
accessibilityElementsHidden={saved}
importantForAccessibility={saved ? "no-hide-descendants" : "auto"}
onLayout={(e: LayoutChangeEvent) => {
if (phase === "writing") full.current = e.nativeEvent.layout.height;
}}
>
<Textarea
placeholder="Write freely, only you can see this."
value={entry}
onChangeText={setEntry}
editable={phase === "writing"}
autoGrow
minHeight={140}
className="text-[17px] leading-6"
accessibilityLabel="Journal entry"
/>
<View className="flex-row flex-wrap gap-2">
{PROMPTS.map((p) => (
<Chip
key={p}
variant="suggestion"
size="sm"
onPress={() => setEntry((e) => (e.trim() ? `${e.trim()}\n\n${p} ` : `${p} `))}
>
{p}
</Chip>
))}
</View>
</Animated.View>
{saved ? (
<Animated.View className="absolute left-0 right-0 top-0" style={rowStyle}>
<Pressable
onPress={reopen}
accessibilityRole="button"
accessibilityLabel={`Entry saved at ${savedAt}. Tap to keep writing.`}
className="h-16 flex-row items-center gap-3 px-5"
>
<View className="h-8 w-8 items-center justify-center rounded-full bg-primary">
<Icon name="check" size="sm" color="primaryForeground" strokeWidth={3} />
</View>
<View className="flex-1">
<Text className="text-[15px] font-semibold text-foreground">Saved · {savedAt}</Text>
<Text className="text-sm text-muted-foreground" numberOfLines={1}>
{entry.trim()}
</Text>
</View>
<Icon name="chevron-right" size="sm" color="mutedForeground" />
</Pressable>
</Animated.View>
) : null}
<Sheen run={sheen} color={colors.primary} strength={0.22} />
</Animated.View>
<Button size="lg" className="w-full" disabled={phase !== "writing" || entry.trim().length === 0} onPress={save}>
{saved ? "Saved" : "Save entry"}
</Button>
</View>
</Accent>
);
} API reference
label string Visible label above the field.
—helper string Helper text below the field.
—error string Error message — turns the field red.
—minHeight number Minimum height in points. Default 96.
96 autoGrow boolean Grow with content.
false showCount boolean Show a live character count under the field ("n" or "n/max" with maxLength).
false className string NativeWind classes for the input.
—glass boolean Glass field — rounded material instead of the flat fill.
false containerClassName string Classes for the outer wrapper.
—multiline boolean true