Lynx

Text Field Input

A component that receives single-line text input and combines it with Field's label, description, and error states.

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

Lynx's TextFieldInput does not support React's autoFocus prop. If you need to focus from the beginning, specify an id for the input and call the focus UI method of Lynx native input after the screen is ready.

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

TextFieldInput

Prop

Type

placeholder?string | undefined
confirm-type?"send" | "search" | "go" | "done" | "next" | undefined
maxlength?number | undefined
readonly?boolean | undefined
disabled?boolean | undefined
input-filter?string | undefined
type?"number" | "text" | "digit" | "password" | "tel" | "email" | undefined
ios-auto-correct?boolean | undefined
ios-spell-check?boolean | undefined
android-fullscreen-mode?boolean | undefined
bindfocus?((e: BaseEvent<"bindfocus", InputFocusEvent>) => void) | undefined
bindblur?((e: BaseEvent<"bindblur", InputBlurEvent>) => void) | undefined
bindconfirm?((e: BaseEvent<"bindconfirm", InputConfirmEvent>) => void) | undefined
bindinput?((e: BaseEvent<"bindinput", InputInputEvent>) => void) | undefined
bindselection?((e: BaseEvent<"bindselection", InputSelectionEvent>) => 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

Specify the TextField size with size. (default: large)

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

Loading Lynx example…

Customizable Parts

When conveying context with just icons, include text describing the icon's meaning in description or label. If the icon itself needs to be read, specify accessibility-label.

Prefix

Loading Lynx example…

Suffix

Loading Lynx example…

Both Affixes

Loading Lynx example…

Indicator

You can use the indicator or showRequiredIndicator prop.

Loading Lynx example…

Grapheme Count

Loading Lynx example…

The result of dividing value into user-perceived character (grapheme cluster) units is provided as graphemes and slicedGraphemes in the onValueChange callback.

Character segmentation is done via 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…

Number Formatting

Loading Lynx example…

Slicing

Loading Lynx example…

Lynx Usage

Keyboard Avoidance

When placed inside KeyboardAvoidingScrollView, TextFieldInput is automatically registered when focused and scrolls to a position not hidden by the keyboard.

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

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

Web Version Differences

  • In the editable state, it renders the Lynx native <input> element instead of the HTML <input>.
  • In the readOnly state, it renders as a <text> element to remove the native focus, selection, and cut menu. The ref in this state points to <text>, and input-only UI methods and events cannot be used.
  • Use onValueChange of the snippet TextField instead of onChange. It provides both the original text and the value cut in grapheme units.
  • The native bindinput can be additionally passed to TextFieldInput.
  • Since there is no DOM id connection between Field.Label and the input, provide accessibility-label directly to the input.
  • The default value of show-soft-input-on-focus is true so that the keyboard appears on focus. The component explicitly applies this default so that undefined is not passed as a native attribute. If you use a custom keyboard, you can override it with false.
  • The default value of android-set-soft-input-mode is "unspecified". Since an error may occur on Android if undefined is passed as a native attribute, the component explicitly applies this default.
  • android-set-soft-input-mode affects the entire host window containing the input element. The default value "unspecified" is not a value that preserves the existing Activity settings, but resets it to the system-determined mode. On a screen where KeyboardAvoidingScrollView is dedicated to keyboard avoidance, override it with "nothing" to prevent separate pan/resize. Use the same value as much as possible for input elements in the same window.
  • size="responsive" is not supported in Lynx, which has no CSS viewport breakpoints. Specify large or medium.

Unsupported Lynx Features

  • HTML form submit, browser validation, React Hook Form, and aria-describedby id connection are not supported.

Table of contents