# Text Field Textarea
URL: /lynx/components/text-field-textarea
Source: https://github.com/daangn/seed-design/blob/dev/docs/content/lynx/components/text-field-textarea.mdx
여러 줄의 긴 텍스트를 입력받고 자동으로 높이를 조절하는 컴포넌트입니다.
사용 가능 버전: @seed-design/lynx-react@0.4.0, @seed-design/lynx-css@0.7.0
## Preview
```tsx
import "./styles";
import { root } from "@lynx-js/react";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import { TextField, TextFieldTextarea } from "@/components/ui/text-field";
function Root() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
);
}
root.render();
```
## Installation
- npm: npx @seed-design/cli add ui:text-field
- pnpm: pnpm dlx @seed-design/cli add ui:text-field
- yarn: yarn dlx @seed-design/cli add ui:text-field
- bun: bun x @seed-design/cli add ui:text-field
## Props
### `TextField`
### `TextFieldTextarea`
## Usage
Snippet의 `TextField`가 label, description, required indicator와 여러 줄 입력 영역을 조합합니다. Lynx에는 HTML `label for` 연결이 없으므로 native 입력에는 `accessibility-label`을 함께 지정합니다.
```tsx
import { TextField, TextFieldTextarea } from "@/components/ui/text-field";
export function IntroductionField() {
return (
);
}
```
### Controlled value
`value`와 `onValueChange`를 전달하면 controlled mode로 동작합니다. Lynx native textarea에는 `value` attribute가 없으므로 컴포넌트가 `setValue` UI method로 값을 동기화합니다.
```tsx
import { useState } from "@lynx-js/react";
import { TextField, TextFieldTextarea } from "@/components/ui/text-field";
export function ControlledIntroduction() {
const [value, setValue] = useState("");
return (
setValue(value)}>
);
}
```
### Autoresizing
`TextFieldTextarea`는 기본적으로 Lynx native textarea의 측정 기능을 사용해 내용에 맞춰 높이가 늘어납니다. iOS에서는 크기 측정용 래퍼가 최소 높이와 세로 여백을 맡고, Android에서는 native textarea가 직접 맡습니다. 실제 영역의 높이가 달라지면 `KeyboardAvoidingScrollView`의 회피 위치를 다시 계산합니다. 고정 높이가 필요하면 `autoresize={false}`와 명시적인 `height`를 함께 사용합니다.
Android에서는 SEED typography의 줄 높이를 맞추기 위해 `line-spacing="3.2px"`를 기본 적용합니다. `line-spacing`을 명시하면 모든 플랫폼에서 해당 값이 우선하며, Android의 기본 보정은 `line-spacing={0}`으로 해제할 수 있습니다. `fontSize`나 `lineHeight`를 직접 변경한다면 이에 맞는 `line-spacing`도 함께 지정해야 합니다.
```tsx
```
### Grapheme limit
이모지·조합 문자를 사용자에게 보이는 한 글자로 계산하려면 snippet의 `maxGraphemeCount`와 `onValueChange`를 사용합니다.
```tsx
import { useState } from "@lynx-js/react";
import { TextField, TextFieldTextarea } from "@/components/ui/text-field";
export function LimitedIntroductionField() {
const [value, setValue] = useState("");
return (
setValue(slicedValue)}
>
);
}
```
### Keyboard avoidance
`KeyboardAvoidingScrollView` 안에 배치하면 `TextFieldTextarea`가 focus될 때 자동으로 등록됩니다. autoresize로 레이아웃이 바뀌면 활성 입력 위치를 다시 계산합니다.
```tsx
import { KeyboardAvoidingScrollView } from "@seed-design/lynx-react";
import { TextField, TextFieldTextarea } from "@/components/ui/text-field";
export function Form() {
return (
);
}
```
## Examples
### State
#### Enabled
기본 상태와 오류 상태를 `Field`의 label, description, error message와 함께 구성합니다.
```tsx
import "./styles";
import { root } from "@lynx-js/react";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import { TextField, TextFieldTextarea } from "@/components/ui/text-field";
function Root() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
);
}
root.render();
```
#### Disabled
`disabled`는 입력과 이를 감싸는 `Field`의 상태를 함께 비활성화합니다.
```tsx
import "./styles";
import { root } from "@lynx-js/react";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import { TextField, TextFieldTextarea } from "@/components/ui/text-field";
function Root() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
);
}
root.render();
```
#### Read Only
`readOnly`는 값을 편집할 수 없는 텍스트로 표시합니다. 비활성 상태와 달리 내용을 읽는 용도로 사용합니다.
```tsx
import "./styles";
import { root } from "@lynx-js/react";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import { TextField, TextFieldTextarea } from "@/components/ui/text-field";
function Root() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
);
}
root.render();
```
### Grapheme Count
`maxGraphemeCount`를 지정하면 현재 글자 수와 최대 글자 수를 표시합니다. 이모지와 조합 문자는 화면에 보이는 grapheme 단위로 계산합니다.
```tsx
import "./styles";
import { root } from "@lynx-js/react";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import { TextField, TextFieldTextarea } from "@/components/ui/text-field";
function Root() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
);
}
root.render();
```
## Web Version Differences
- 편집 가능한 상태에서는 HTML `