Lynx

Text Field Textarea

A component that accepts multi-line text input and automatically adjusts its height.

Engine ≥ 3.6<textarea>
Available since@seed-design/lynx-react@0.4.0, @seed-design/lynx-css@0.7.0
Loading Lynx example…

Props corresponding to React's autoFocus are not supported. If you need to focus from the beginning, call the native focus UI method on the TextFieldTextarea ref after the screen is rendered.

Installation

npx @seed-design/cli add ui:text-field

Props

TextField

Prop

Type

children?React.ReactNode
label?React.ReactNode
labelWeight?"medium" | "bold" | undefined
indicator?React.ReactNode
prefixIcon?React.ReactElement<LynxIconElementProps, string | React.JSXElementConstructor<any>> | undefined
prefix?React.ReactNode
suffixIcon?React.ReactElement<LynxIconElementProps, string | React.JSXElementConstructor<any>> | undefined
suffix?React.ReactNode
description?React.ReactNode
errorMessage?React.ReactNode
hideCharacterCount?boolean | undefined
maxGraphemeCount?number | undefined
showRequiredIndicator?boolean | undefined
fieldRef?React.Ref<NodesRef> | undefined
onValueChange?((values: { value: string; graphemes: string[]; slicedValue: string; slicedGraphemes: string[]; }) => void) | undefined
value?string | undefined
defaultValue?string | undefined
required?boolean | undefined
name?string | undefined
style?CSSProperties | undefined
className?string | undefined

TextFieldTextarea

Prop

Type

placeholder?string | undefined
confirm-type?"send" | "search" | "go" | "done" | "next" | undefined
maxlength?number | undefined
maxlines?number | undefined
bounces?boolean | undefined
readonly?boolean | undefined
disabled?boolean | undefined
input-filter?string | undefined
enable-scroll-bar?boolean | undefined
type?"number" | "text" | "digit" | "tel" | "email" | undefined
ios-auto-correct?boolean | undefined
ios-spell-check?boolean | undefined
bindfocus?((e: BaseEvent<"bindfocus", TextAreaFocusEvent>) => void) | undefined
bindblur?((e: BaseEvent<"bindblur", TextAreaBlurEvent>) => void) | undefined
bindconfirm?((e: BaseEvent<"bindconfirm", TextAreaConfirmEvent>) => void) | undefined
bindinput?((e: BaseEvent<"bindinput", TextAreaInputEvent>) => void) | undefined
bindselection?((e: BaseEvent<"bindselection", TextAreaSelectionChangeEvent>) => void) | undefined
id?string | undefined
name?string | undefined
hidden?boolean | undefined
flatten?boolean | undefined
focusable?boolean | undefined
bindlayoutchange?EventHandler<LayoutChangeDetailEvent<Target>> | undefined
main-thread:bindlayoutchange?EventHandler<LayoutChangeDetailEvent<Element>> | undefined
style?CSSProperties | undefined
className?string | undefined

Examples

State

Enabled

Loading Lynx example…

Disabled

Loading Lynx example…

Read Only

Loading Lynx example…

Size

Set the size of TextField with size. (default: large)

Lynx supports large and medium. responsive is not supported because there is no CSS viewport breakpoint.

Loading Lynx example…

Sizing

You can fix the height or set the minimum/maximum height by directly specifying height-related styles to <TextFieldTextarea>.

Fixed Height

When using a fixed height, specify autoresize={false} and an explicit height together.

Loading Lynx example…

Auto Height with Constraints

Loading Lynx example…

Customizable Parts

Indicator

You can use the indicator or showRequiredIndicator prop.

Loading Lynx example…

Grapheme Count

Loading Lynx example…

Provides the result of splitting value into user-perceivable character (grapheme cluster) units via graphemes and slicedGraphemes in the onValueChange callback.

Character segmentation is done through unicode-segmenter.

Loading Lynx example…

Use Cases

Controlled State

Lynx does not support HTML forms. You can manage input values as React state using value and onValueChange.

Loading Lynx example…

Formatting

Loading Lynx example…

Slicing

Loading Lynx example…

Lynx Usage

Autoresizing

TextFieldTextarea by default uses the measurement capability of the Lynx native textarea to automatically increase its height to fit the content. On iOS, the sizing wrapper handles minimum height and vertical padding, while on Android, the native textarea handles it directly. When the actual area height changes, KeyboardAvoidingScrollView recalculates the avoidance position.

On Android, line-spacing="3.2px" is applied by default to match the line height of Crispy typography. When line-spacing is specified, that value takes priority on all platforms, and Android's default correction can be disabled with line-spacing={0}. If you directly change fontSize or lineHeight, you must also specify the corresponding line-spacing.

Keyboard Avoidance

When placed inside KeyboardAvoidingScrollView, TextFieldTextarea is automatically registered when focused. When the layout changes due to autoresize, the active input position is recalculated.

import { KeyboardAvoidingScrollView } from "@seed-design/lynx-react";
import { TextField, TextFieldTextarea } from "@/components/ui/text-field";

export function KeyboardAwareFields() {
  return (
    <KeyboardAvoidingScrollView>
      <TextField label="Content">
        <TextFieldTextarea accessibility-label="Content" />
      </TextField>
    </KeyboardAvoidingScrollView>
  );
}

Web Version Differences

  • In editable state, renders a Lynx native <textarea> element instead of HTML <textarea>.
  • In readOnly state, renders as a <text> element to remove native focus, selection, and cut menus. The ref in this state points to <text> and textarea-specific UI methods and events are not available.
  • Uses onValueChange from TextField instead of onChange. Provides both the original text and values sliced at grapheme units.
  • The native bindinput can be additionally passed to TextFieldTextarea.
  • Since there is no DOM id connection between Field.Label and input, accessibility-label is provided directly to the input.
  • Autoresize uses native intrinsic height instead of DOM scrollHeight. On iOS, the sizing wrapper owns vertical padding and minimum height to prevent duplication with native content size on first input. On Android, the native textarea owns vertical padding and minimum height directly.
  • On Android, CSS line-height is not applied to native textarea, so line-spacing="3.2px" is applied by default. An explicit line-spacing value takes priority over this default.
  • Controlled textarea also maintains native input events as-is and synchronizes via setValue only when the value changes from outside. Since readonly is not toggled on each input, native scroll offset and height measurement are not reset when lines are added.
  • The default value of show-soft-input-on-focus is true to make the keyboard appear on focus. The component explicitly applies this default value to prevent undefined from being passed as a native attribute. If using a custom keyboard, it can be redefined to false.
  • Android's fullscreen extract input is disabled by default. When needed, explicitly set android-fullscreen-mode={true}.
  • The default value of android-set-soft-input-mode is "unspecified". Since passing undefined as a native attribute on Android can cause errors, the component explicitly applies this default value.
  • android-set-soft-input-mode affects the entire host window containing the input element. The default "unspecified" does not preserve the existing Activity setting but resets it to system-determined mode. On screens where KeyboardAvoidingScrollView handles keyboard avoidance exclusively, it is redefined to "nothing" to prevent separate pan/resize. Use the same value when possible for input elements in the same window.
  • size="responsive" is not supported in Lynx because there is no CSS viewport breakpoint. Explicitly use large or medium.

Unsupported Lynx Features

  • HTML form submit, browser validation, React Hook Form, and aria-describedby id connection are not supported.
  • In large textareas, keyboard avoidance based only on the current caret position is not supported. Currently, the largest area that fits within the safe area among Field, TextField, and native input areas is selected.

Table of contents