본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Textarea

원문 보기 위키 갱신

여러 줄의 텍스트 값을 입력받을 때 사용하는 컴포넌트입니다. 긴 자유 형식 텍스트(메모, 설명 등)를 받는 폼에서 TextInput 대신 쓰여요. 크기 조정(resize), 너비·높이 맞춤, 자동 크기 확장(autoSize), 검증 상태 같은 다양한 옵션을 제공합니다.

출처: 문서

본문

Textarea는 여러 줄의 텍스트 값(multiple lines of text)을 설정할 때 사용합니다.

React 예시

기본 (Default)

<FormControl>
  <FormControl.Label>Label</FormControl.Label>
  <Textarea />
</FormControl>

크기 조정 동작 (Resize behavior)

크기 조정 가이드라인을 참고하세요. 이 예시는 Textarea가 어느 방향으로도 크기 조정되지 않게 막지만, 크기 조정을 가로나 세로로만 제한할 수도 있습니다.

<FormControl>
  <FormControl.Label>Label</FormControl.Label>
  <Textarea resize="none" />
</FormControl>

너비 맞춤 (Customized width)

기본값은 30자 너비입니다. 임의의 문자 수로 설정하거나 부모 너비를 채우도록 설정할 수 있습니다. 100% 너비가 필요하면 block prop을 대신 사용하세요.

<FormControl>
  <FormControl.Label>Label</FormControl.Label>
  <Textarea cols={60} />
</FormControl>

높이 맞춤 (Customized height)

기본값은 7줄입니다. 예상 콘텐츠 길이에 따라 임의의 줄 수로 조정할 수 있고, 콘텐츠가 설정된 높이를 넘으면 사용자가 스크롤할 수 있습니다.

<FormControl>
  <FormControl.Label>Label</FormControl.Label>
  <Textarea rows={3} />
</FormControl>

필수 (Required)

<FormControl required>
  <FormControl.Label>Label</FormControl.Label>
  <Textarea />
</FormControl>

캡션과 함께 (With a caption)

<FormControl>
  <FormControl.Label>Label</FormControl.Label>
  <Textarea />
  <FormControl.Caption>This is a caption</FormControl.Caption>
</FormControl>

검증 메시지와 함께 (With a validation message)

<FormControl>
  <FormControl.Label>Label</FormControl.Label>
  <Textarea />
  <FormControl.Validation variant="error">Something went wrong</FormControl.Validation>
</FormControl>

Props

Textarea

Name Default Description
required — boolean — 필드 값이 필수임을 사용자와 보조 기술에 알립니다.
cols — number — 텍스트 영역의 보이는 너비를 지정합니다.
rows — number — 텍스트 영역의 보이는 높이를 지정합니다.
block false boolean — 컴포넌트의 너비를 확장해 부모 요소를 채웁니다.
resize 'both' 'both' | 'horizontal' | 'vertical' | 'none' — 크기 조정 동작을 바꿉니다.
autoSize false boolean — 텍스트 영역이 콘텐츠에 맞게 자라나도록 허용합니다.
characterLimit — number — 텍스트 영역에 허용되는 최대 문자 수입니다.
contrast false boolean — 배경색을 더 높은 대비 색으로 바꿉니다.
validationStatus — 'success' | 'error' | undefined — 현재 폼 검증 상태에 맞게 텍스트 영역을 스타일링합니다.
ref — React.RefObject<HTMLTextAreaElement> —
as "input" React.ElementType — 렌더링할 요소 타입입니다.
className — string | undefined — 래퍼 요소에 적용할 className입니다.
minHeight — number — 텍스트 영역의 최소 높이입니다.
maxHeight — number — 텍스트 영역의 최대 높이입니다.

관련 링크

  • Forms
  • TextInput

더 알아보기 (Learn more)