Lynx

Text Field Input

한 줄 텍스트를 입력받고 Field의 레이블·설명·오류 상태와 조합하는 컴포넌트입니다.

Engine ≥ 3.6<input>
사용 가능 버전@seed-design/[email protected], @seed-design/[email protected]
Lynx 예제를 불러오는 중입니다.

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

Lynx 예제를 불러오는 중입니다.

Disabled

Lynx 예제를 불러오는 중입니다.

Read Only

Lynx 예제를 불러오는 중입니다.

Size

size로 TextField의 크기를 정합니다. (default: large)

Lynx에서는 largemedium을 지원합니다. CSS viewport breakpoint가 없어 responsive는 지원하지 않습니다.

Lynx 예제를 불러오는 중입니다.

Customizable Parts

아이콘만으로 맥락을 전달할 때는 description 또는 label에 아이콘의 의미를 설명하는 텍스트를 포함하세요. 아이콘 자체를 읽어야 한다면 accessibility-label을 지정하세요.

Prefix

Lynx 예제를 불러오는 중입니다.

Suffix

Lynx 예제를 불러오는 중입니다.

Both Affixes

Lynx 예제를 불러오는 중입니다.

Indicator

indicator 또는 showRequiredIndicator prop을 사용할 수 있습니다.

Lynx 예제를 불러오는 중입니다.

Grapheme Count

Lynx 예제를 불러오는 중입니다.

value를 사용자 인식 문자(grapheme cluster) 단위로 나눈 결과를 onValueChange 콜백의 graphemesslicedGraphemes로 제공합니다.

문자 분리는 unicode-segmenter를 통해 이루어집니다.

Lynx 예제를 불러오는 중입니다.

Use Cases

Controlled State

Lynx는 HTML Form을 지원하지 않습니다. valueonValueChange를 사용해 입력값을 React state로 관리할 수 있습니다.

Lynx 예제를 불러오는 중입니다.

Number Formatting

Lynx 예제를 불러오는 중입니다.

Slicing

Lynx 예제를 불러오는 중입니다.

Lynx Usage

Keyboard Avoidance

KeyboardAvoidingScrollView 안에 배치하면 TextFieldInput이 focus될 때 자동으로 등록되어 키보드에 가려지지 않는 위치로 스크롤됩니다.

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

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

Web Version Differences

  • 편집 가능한 상태에서는 HTML <input> 대신 Lynx native <input> element를 렌더링합니다.
  • readOnly 상태에서는 native focus·selection·잘라내기 메뉴를 제거하기 위해 <text> element로 렌더링합니다. 이 상태의 ref는 <text>를 가리키며 input 전용 UI method와 이벤트는 사용할 수 없습니다.
  • onChange 대신 snippet TextFieldonValueChange를 사용합니다. 원문과 grapheme 단위로 자른 값을 함께 제공합니다.
  • native bindinputTextFieldInput에 추가로 전달할 수 있습니다.
  • Field.Label과 입력의 DOM id 연결이 없으므로 accessibility-label을 입력에 직접 제공합니다.
  • 포커스 시 키보드가 나타나도록 show-soft-input-on-focus의 기본값은 true입니다. undefined가 native attribute로 전달되지 않도록 컴포넌트가 이 기본값을 명시적으로 적용합니다. 커스텀 키보드를 사용하는 경우에는 false로 재정의할 수 있습니다.
  • android-set-soft-input-mode의 기본값은 "unspecified"입니다. Android에서 undefined가 native attribute로 전달되면 오류가 발생할 수 있어 컴포넌트가 이 기본값을 명시적으로 적용합니다.
  • android-set-soft-input-mode는 입력 요소가 포함된 host window 전역에 영향을 줍니다. 기본값인 "unspecified"도 기존 Activity 설정을 그대로 보존하는 값이 아니라 시스템 판단 모드로 다시 설정합니다. KeyboardAvoidingScrollView가 키보드 회피를 전담하는 화면에서는 별도 pan/resize를 막기 위해 "nothing"으로 재정의합니다. 같은 window에 있는 입력 요소에는 가능한 한 같은 값을 사용합니다.
  • size="responsive"는 CSS viewport breakpoint가 없는 Lynx에서 지원하지 않습니다. large 또는 medium을 명시합니다.

Unsupported Lynx Features

  • HTML form submit, browser validation, React Hook Form, aria-describedby id 연결은 지원하지 않습니다.

Last updated on

목차