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

Textarea

원문 보기 위키 갱신

Textarea는 자동 크기 조절(auto-resize)을 지원하는 styled가 없는 다중 줄 텍스트 입력 컴포넌트예요. 레이아웃과 스타일을 완전히 제어해 커스텀한 여러 줄 텍스트 입력을 만들 수 있어요.

출처: 문서

본문

기능 (Features)

  • 네이티브 <textarea> 요소를 렌더링하는 단일 컴포넌트
  • JavaScript 폴백과 함께 CSS field-sizing을 사용해 콘텐츠에 따라 높이를 조절하는 내장 자동 크기 조절
  • 네이티브 <textarea> 시맨틱과 완전한 HTML 속성 지원

사용법 (Usage)

import { Textarea } from 'primereact/textarea';
<Textarea rows={5} cols={30} />

동작 (Behavior)

다형적 렌더링 (Polymorphic Rendering)

as를 사용해 렌더링되는 HTML 요소를 바꾸거나 커스텀 React 컴포넌트를 사용할 수 있어요.

<Textarea as="div" contentEditable role="textbox" />

렌더 함수 자식 (Render Function Children)

Textarea는 렌더 함수를 자식으로 받아 컴포넌트 인스턴스에 접근할 수 있게 해 줘요.

<Textarea>{(instance) => <span>Custom render</span>}</Textarea>

패스 스루 (Pass Through)

<DocPTViewer name="textarea-pt" components={['Textarea']} />

API

Textarea

Attribute Value
data-scope "textarea"
data-part "root"
data-invalid Present when invalid
Label Type Description
root TextareaPassThroughType<TextareaHTMLAttributes> Used to pass attributes to the root's DOM element.

접근성 (Accessibility)

스크린 리더 (Screen Reader)

Textarea는 네이티브 textarea 요소를 렌더링해요. 보이는 라벨, aria-label, 또는 aria-labelledby로 접근 가능한 이름을 제공해 주세요.

키보드 지원 (Keyboard Support)

Textarea는 네이티브 textarea 키보드 동작을 사용해요.

더 알아보기 (Learn more)