A component that receives single-line text input and combines it with Field's label, description, and error states.
@seed-design/lynx-react@0.4.0, @seed-design/lynx-css@0.7.0
import "./styles" ;
import { VStack, useSeedClassName } from "@seed-design/lynx-react" ;
import { TextField, TextFieldInput } from "@/components/ui/text-field" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-text-field-input-root` }>
< VStack className = "text-field-input-preview" >
< VStack className = "text-field-input-preview__content" >
< TextField label = "라벨" >
< TextFieldInput accessibility-label = "라벨" />
</ TextField >
</ VStack >
</ VStack >
</ view >
);
}
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.
npx @seed-design/cli add ui:text-field pnpm dlx @seed-design/cli add ui:text-field yarn dlx @seed-design/cli add ui:text-field bun x @seed-design/cli add ui:text-field
Install dependencies
npm install @seed-design/lynx-react yarn add @seed-design/lynx-react pnpm add @seed-design/lynx-react bun add @seed-design/lynx-react Copy the code below and paste it in /**
* @file ui:text-field
* @requires @seed-design/lynx-react@>=0.1.0 <1.0.0
* @requires @seed-design/lynx-css@>=0.1.0 <1.0.0
**/
import * as React from "@lynx-js/react" ;
import {
Field as SeedField,
TextField as SeedTextField,
type UseTextFieldWithGraphemesParams,
useTextFieldWithGraphemes,
} from "@seed-design/lynx-react" ;
type TextFieldRootRef = React . ComponentRef < typeof SeedTextField.Root>;
type FieldRootRef = React . ComponentRef < typeof SeedField.Root>;
export interface TextFieldProps
extends Omit < SeedTextField . RootProps , "children" | "onValueChange" > {
children ?: React . ReactNode ;
label ?: React . ReactNode ;
labelWeight ?: SeedField . LabelProps [ "weight" ];
indicator ?: React . ReactNode ;
prefixIcon ?: SeedTextField . PrefixIconProps [ "icon" ];
prefix ?: React . ReactNode ;
suffixIcon ?: SeedTextField . SuffixIconProps [ "icon" ];
suffix ?: React . ReactNode ;
description ?: React . ReactNode ;
errorMessage ?: React . ReactNode ;
hideCharacterCount ?: boolean ;
maxGraphemeCount ?: number ;
showRequiredIndicator ?: boolean ;
fieldRef ?: React . Ref < FieldRootRef >;
onValueChange ?: UseTextFieldWithGraphemesParams [ "onValueChange" ];
}
/**
* @see https://crispy.carrot-soft.tech/lynx/components/text-field-input
*/
export const TextField = React. forwardRef < TextFieldRootRef , TextFieldProps >(
(
{
children,
label,
labelWeight,
indicator,
prefixIcon,
prefix,
suffixIcon,
suffix,
description,
errorMessage,
hideCharacterCount,
maxGraphemeCount,
showRequiredIndicator,
fieldRef,
value,
defaultValue,
onValueChange,
required,
disabled,
invalid,
readOnly,
name,
... rootProps
},
ref,
) => {
const { textFieldRootProps , counterProps } = useTextFieldWithGraphemes ({
value,
defaultValue,
onValueChange,
maxGraphemeCount,
});
const renderHeader = label != null || indicator != null ;
const renderDescription = description != null && ! (invalid && errorMessage != null );
const renderErrorMessage = invalid && errorMessage != null ;
const renderCharacterCount = ! hideCharacterCount && maxGraphemeCount !== undefined ;
const renderFooter = renderDescription || renderErrorMessage || renderCharacterCount;
return (
< SeedField.Root
ref = {fieldRef}
required = {required}
disabled = {disabled}
invalid = {invalid}
readOnly = {readOnly}
>
{renderHeader ? (
< SeedField.Header >
< SeedField.Label weight = {labelWeight}>
{label}
{showRequiredIndicator ? < SeedField.RequiredIndicator /> : null }
{indicator != null ? (
< SeedField.IndicatorText >{indicator}</ SeedField.IndicatorText >
) : null }
</ SeedField.Label >
</ SeedField.Header >
) : null }
< SeedTextField.Root ref = {ref} name = {name} { ... rootProps} { ... textFieldRootProps}>
{prefixIcon ? < SeedTextField.PrefixIcon icon = {prefixIcon} /> : null }
{prefix != null ? < SeedTextField.PrefixText >{prefix}</ SeedTextField.PrefixText > : null }
{children}
{suffix != null ? < SeedTextField.SuffixText >{suffix}</ SeedTextField.SuffixText > : null }
{suffixIcon ? < SeedTextField.SuffixIcon icon = {suffixIcon} /> : null }
</ SeedTextField.Root >
{renderFooter ? (
< SeedField.Footer >
{renderDescription ? (
< SeedField.Description >{description}</ SeedField.Description >
) : null }
{renderErrorMessage ? (
< SeedField.ErrorMessage >{errorMessage}</ SeedField.ErrorMessage >
) : null }
{renderCharacterCount ? < SeedField.CharacterCount { ... counterProps} /> : null }
</ SeedField.Footer >
) : null }
</ SeedField.Root >
);
},
);
TextField.displayName = "TextField" ;
export interface TextFieldInputProps extends SeedTextField . InputProps {}
/**
* @see https://crispy.carrot-soft.tech/lynx/components/text-field-input
*/
export const TextFieldInput = SeedTextField.Input;
export interface TextFieldTextareaProps extends SeedTextField . TextareaProps {}
/**
* @see https://crispy.carrot-soft.tech/lynx/components/text-field-textarea
*/
export const TextFieldTextarea = SeedTextField.Textarea;
/**
* This file is a snippet from Crispy, helping you get started quickly with @seed-design/* packages.
* You can extend this snippet however you want.
*/
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
variant?"outline" | "underline" | undefined
size?"medium" | "large" | undefined
invalid?boolean | undefined
readOnly?boolean | undefined
disabled?boolean | undefined
value?string | undefined
defaultValue?string | undefined
required?boolean | undefined
name?string | undefined
style?CSSProperties | undefined
className?string | undefined
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
import "./styles" ;
import { useSeedClassName, VStack } from "@seed-design/lynx-react" ;
import { TextField, TextFieldInput } from "@/components/ui/text-field" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-text-field-input-root` }>
< VStack className = "text-field-input-preview" >
< VStack className = "text-field-input-preview__content" gap = "spacingY.componentDefault" >
< TextField label = "라벨" description = "설명을 써주세요" >
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
< TextField
label = "라벨"
description = "설명을 써주세요"
invalid
errorMessage = "오류가 발생한 이유를 써주세요"
>
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
< TextField variant = "underline" description = "설명을 써주세요" >
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
< TextField
variant = "underline"
description = "설명을 써주세요"
invalid
errorMessage = "오류가 발생한 이유를 써주세요"
>
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
</ VStack >
</ VStack >
</ view >
);
}
import "./styles" ;
import { useSeedClassName, VStack } from "@seed-design/lynx-react" ;
import { TextField, TextFieldInput } from "@/components/ui/text-field" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-text-field-input-root` }>
< VStack className = "text-field-input-preview" >
< VStack className = "text-field-input-preview__content" gap = "spacingY.componentDefault" >
< TextField label = "라벨" description = "설명을 써주세요" disabled >
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
< TextField
label = "라벨"
description = "설명을 써주세요"
disabled
invalid
errorMessage = "오류가 발생한 이유를 써주세요"
>
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
< TextField variant = "underline" description = "설명을 써주세요" disabled >
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
< TextField
variant = "underline"
description = "설명을 써주세요"
disabled
invalid
errorMessage = "오류가 발생한 이유를 써주세요"
>
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
</ VStack >
</ VStack >
</ view >
);
}
import "./styles" ;
import { useSeedClassName, VStack } from "@seed-design/lynx-react" ;
import { TextField, TextFieldInput } from "@/components/ui/text-field" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-text-field-input-root` }>
< VStack className = "text-field-input-preview" >
< VStack className = "text-field-input-preview__content" gap = "spacingY.componentDefault" >
< TextField label = "라벨" description = "설명을 써주세요" readOnly >
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
< TextField
label = "라벨"
description = "설명을 써주세요"
readOnly
invalid
errorMessage = "오류가 발생한 이유를 써주세요"
>
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
< TextField variant = "underline" description = "설명을 써주세요" readOnly >
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
< TextField
variant = "underline"
description = "설명을 써주세요"
readOnly
invalid
errorMessage = "오류가 발생한 이유를 써주세요"
>
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
</ VStack >
</ VStack >
</ view >
);
}
Specify the TextField size with size. (default: large)
Lynx supports large and medium. responsive is not supported because there are no CSS viewport breakpoints.
import "./styles" ;
import { useSeedClassName, VStack } from "@seed-design/lynx-react" ;
import { TextField, TextFieldInput } from "@/components/ui/text-field" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-text-field-input-root` }>
< VStack className = "text-field-input-preview" >
< VStack className = "text-field-input-preview__content" gap = "spacingY.componentDefault" >
< TextField label = "라벨" description = "size=large (default)" size = "large" >
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
< TextField label = "라벨" description = "size=medium" size = "medium" >
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
< TextField variant = "underline" description = "size=large (default)" size = "large" >
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
< TextField variant = "underline" description = "size=medium" size = "medium" >
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
</ VStack >
</ VStack >
</ view >
);
}
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.
import "./styles" ;
import IconMagnifyingglassLine from "@karrotmarket/lynx-monochrome-icon/IconMagnifyingglassLine" ;
import { useSeedClassName, VStack } from "@seed-design/lynx-react" ;
import { TextField, TextFieldInput } from "@/components/ui/text-field" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-text-field-input-root` }>
< VStack className = "text-field-input-preview" >
< VStack className = "text-field-input-preview__content" gap = "spacingY.componentDefault" >
< TextField
label = "소셜 미디어 URL"
description = "프로필이나 페이지 URL을 입력해주세요."
prefix = "https://"
>
< TextFieldInput accessibility-label = "소셜 미디어 URL" placeholder = "example.com" />
</ TextField >
< TextField
label = "검색"
description = "글 제목 또는 내용으로 검색할 수 있습니다."
prefixIcon = {< IconMagnifyingglassLine />}
>
< TextFieldInput accessibility-label = "검색" placeholder = "레모네이드 레시피" />
</ TextField >
< TextField
variant = "underline"
description = "프로필이나 페이지 URL을 입력해주세요."
prefix = "https://"
>
< TextFieldInput accessibility-label = "소셜 미디어 URL" placeholder = "example.com" />
</ TextField >
< TextField
variant = "underline"
description = "글 제목 또는 내용으로 검색할 수 있습니다."
prefixIcon = {< IconMagnifyingglassLine />}
>
< TextFieldInput accessibility-label = "검색" placeholder = "레모네이드 레시피" />
</ TextField >
</ VStack >
</ VStack >
</ view >
);
}
import "./styles" ;
import IconWonLine from "@karrotmarket/lynx-monochrome-icon/IconWonLine" ;
import { useSeedClassName, VStack } from "@seed-design/lynx-react" ;
import { TextField, TextFieldInput } from "@/components/ui/text-field" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-text-field-input-root` }>
< VStack className = "text-field-input-preview" >
< VStack className = "text-field-input-preview__content" gap = "spacingY.componentDefault" >
< TextField label = "너비" description = "직접 측정 후 입력해주세요." suffix = "cm" >
< TextFieldInput accessibility-label = "너비" placeholder = "200" />
</ TextField >
< TextField label = "금액" description = "단위: 원" suffixIcon = {< IconWonLine />}>
< TextFieldInput accessibility-label = "금액" placeholder = "50,000" />
</ TextField >
< TextField variant = "underline" description = "직접 측정 후 입력해주세요." suffix = "cm" >
< TextFieldInput accessibility-label = "너비" placeholder = "200" />
</ TextField >
< TextField variant = "underline" description = "단위: 원" suffixIcon = {< IconWonLine />}>
< TextFieldInput accessibility-label = "금액" placeholder = "50,000" />
</ TextField >
</ VStack >
</ VStack >
</ view >
);
}
import "./styles" ;
import IconPlusCircleLine from "@karrotmarket/lynx-monochrome-icon/IconPlusCircleLine" ;
import IconWonLine from "@karrotmarket/lynx-monochrome-icon/IconWonLine" ;
import { useSeedClassName, VStack } from "@seed-design/lynx-react" ;
import { TextField, TextFieldInput } from "@/components/ui/text-field" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-text-field-input-root` }>
< VStack className = "text-field-input-preview" >
< VStack className = "text-field-input-preview__content" gap = "spacingY.componentDefault" >
< TextField
label = "나이"
description = "오늘 기준, 만 나이를 입력해주세요."
prefix = "만"
suffix = "세"
>
< TextFieldInput accessibility-label = "나이" placeholder = "플레이스홀더" />
</ TextField >
< TextField
label = "금액"
description = "정산할 금액을 입력해주세요."
prefixIcon = {< IconPlusCircleLine />}
suffixIcon = {< IconWonLine accessibility-label = "원" />}
>
< TextFieldInput accessibility-label = "금액" placeholder = "플레이스홀더" />
</ TextField >
< TextField
variant = "underline"
description = "오늘 기준, 만 나이를 입력해주세요."
prefix = "만"
suffix = "세"
>
< TextFieldInput accessibility-label = "나이" placeholder = "플레이스홀더" />
</ TextField >
< TextField
variant = "underline"
description = "정산할 금액을 입력해주세요."
prefixIcon = {< IconPlusCircleLine />}
suffixIcon = {< IconWonLine accessibility-label = "원" />}
>
< TextFieldInput accessibility-label = "금액" placeholder = "플레이스홀더" />
</ TextField >
</ VStack >
</ VStack >
</ view >
);
}
You can use the indicator or showRequiredIndicator prop.
import "./styles" ;
import { useSeedClassName, VStack } from "@seed-design/lynx-react" ;
import { TextField, TextFieldInput } from "@/components/ui/text-field" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-text-field-input-root` }>
< VStack className = "text-field-input-preview" >
< VStack className = "text-field-input-preview__content" gap = "spacingY.componentDefault" >
< TextField
label = "선택 필드"
labelWeight = "bold"
description = "설명을 써주세요"
indicator = "선택"
>
< TextFieldInput accessibility-label = "선택 필드" placeholder = "플레이스홀더" />
</ TextField >
< TextField label = "필수 필드" description = "설명을 써주세요" required >
< TextFieldInput accessibility-label = "필수 필드" placeholder = "플레이스홀더" />
</ TextField >
< TextField label = "필수 필드" description = "설명을 써주세요" required showRequiredIndicator >
< TextFieldInput accessibility-label = "필수 필드" placeholder = "플레이스홀더" />
</ TextField >
</ VStack >
</ VStack >
</ view >
);
}
import "./styles" ;
import { useSeedClassName, VStack } from "@seed-design/lynx-react" ;
import { TextField, TextFieldInput } from "@/components/ui/text-field" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-text-field-input-root` }>
< VStack className = "text-field-input-preview" >
< VStack className = "text-field-input-preview__content" gap = "spacingY.componentDefault" >
< TextField label = "라벨" description = "설명을 써주세요" maxGraphemeCount = { 8 }>
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
< TextField
label = "라벨"
description = "설명을 써주세요"
maxGraphemeCount = { 8 }
invalid
errorMessage = "에러 메시지"
>
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
</ VStack >
</ VStack >
</ view >
);
}
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 .
import "./styles" ;
import { useState } from "@lynx-js/react" ;
import { useSeedClassName, VStack } from "@seed-design/lynx-react" ;
import { TextField, TextFieldInput } from "@/components/ui/text-field" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
const [ value , setValue ] = useState ( "" );
const [ graphemes , setGraphemes ] = useState < string []>([]);
return (
< view className = { `${ seedClassName } docs-lynx-text-field-input-root` }>
< VStack className = "text-field-input-preview" >
< VStack className = "text-field-input-preview__content" gap = "x4" >
< TextField
label = "라벨"
description = "국기 이모지 🇰🇷 를 추가해보세요."
maxGraphemeCount = { 100 }
value = {value}
onValueChange = {({ slicedValue , slicedGraphemes }) => {
setValue (slicedValue);
setGraphemes (slicedGraphemes);
}}
>
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
< VStack gap = "x2" >
< text className = "text-field-input-preview__status" >
graphemes.length: { JSON . stringify (graphemes. length )}
</ text >
< text className = "text-field-input-preview__status" >
value.length: { JSON . stringify (value. length )}
</ text >
< text className = "text-field-input-preview__status" >
graphemes: { JSON . stringify (graphemes)}
</ text >
< text className = "text-field-input-preview__status" >value: {value}</ text >
</ VStack >
</ VStack >
</ VStack >
</ view >
);
}
Lynx does not support HTML Forms. You can manage input values as React state using value and onValueChange.
import "./styles" ;
import { useState } from "@lynx-js/react" ;
import { useSeedClassName, VStack } from "@seed-design/lynx-react" ;
import { TextField, TextFieldInput } from "@/components/ui/text-field" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
const [ value , setValue ] = useState ( "안녕하세요" );
return (
< view className = { `${ seedClassName } docs-lynx-text-field-input-root` }>
< VStack className = "text-field-input-preview" >
< VStack className = "text-field-input-preview__content" gap = "x3" >
< TextField
label = "이름"
description = "입력값을 React state로 관리합니다."
value = {value}
onValueChange = {({ value : nextValue }) => setValue (nextValue)}
>
< TextFieldInput accessibility-label = "이름" placeholder = "홍길동" />
</ TextField >
< text className = "text-field-input-preview__status" >입력값: {value}</ text >
</ VStack >
</ VStack >
</ view >
);
}
import "./styles" ;
import { useState } from "@lynx-js/react" ;
import { useSeedClassName, VStack } from "@seed-design/lynx-react" ;
import { TextField, TextFieldInput } from "@/components/ui/text-field" ;
function formatNumber ( value : string ) {
if (value === "" ) return value;
const number = Number (value. replace ( / , / g , "" ));
if (Number. isNaN (number)) return "" ;
return number. toLocaleString ();
}
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
const [ value , setValue ] = useState ( "1000" );
const formattedValue = formatNumber (value);
return (
< view className = { `${ seedClassName } docs-lynx-text-field-input-root` }>
< VStack className = "text-field-input-preview" >
< VStack className = "text-field-input-preview__content" >
< TextField
label = "금액"
description = "금액을 써주세요"
value = {formattedValue}
onValueChange = {({ value : nextValue }) => setValue (nextValue)}
>
< TextFieldInput accessibility-label = "금액" placeholder = "9,999,999" />
</ TextField >
</ VStack >
</ VStack >
</ view >
);
}
import "./styles" ;
import { useState } from "@lynx-js/react" ;
import { useSeedClassName, VStack } from "@seed-design/lynx-react" ;
import { TextField, TextFieldInput } from "@/components/ui/text-field" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
const [ value , setValue ] = useState ( "" );
return (
< view className = { `${ seedClassName } docs-lynx-text-field-input-root` }>
< VStack className = "text-field-input-preview" >
< VStack className = "text-field-input-preview__content" >
< TextField
label = "라벨"
description = "6글자까지 입력 가능합니다"
maxGraphemeCount = { 6 }
value = {value}
onValueChange = {({ slicedValue }) => setValue (slicedValue)}
>
< TextFieldInput accessibility-label = "라벨" placeholder = "플레이스홀더" />
</ TextField >
</ VStack >
</ VStack >
</ view >
);
}
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 >
);
}
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.
HTML form submit, browser validation, React Hook Form, and aria-describedby id connection are not supported.