InputText
InputText는 데이터 속성과 네이티브 입력 시맨틱을 가진 styled가 없는 텍스트 입력 컴포넌트예요. 레이아웃과 스타일을 완전히 제어해 커스텀한 텍스트 입력을 만들 수 있어요.
출처: 문서
본문
기능 (Features)
- 기본
type="text"를 가진 네이티브<input>을 렌더링하는 단일 컴포넌트 - 완전한 HTML 속성 지원을 가진 네이티브
<input>시맨틱
사용법 (Usage)
import { InputText } from 'primereact/inputtext';
<InputText placeholder="Enter text" />
동작 (Behavior)
다형적 렌더링 (Polymorphic Rendering)
as를 사용해 렌더링되는 HTML 요소를 바꾸거나 커스텀 React 컴포넌트를 사용할 수 있어요.
<InputText as={CustomInput} placeholder="Search..." />
렌더 함수 자식 (Render Function Children)
InputText는 렌더 함수를 자식으로 받아 컴포넌트 인스턴스에 접근할 수 있게 해 줘요.
<InputText>{(instance) => <span>Custom render</span>}</InputText>
패스 스루 (Pass Through)
<DocPTViewer name="inputtext-pt" components={['InputText']} />
API
InputText
| Attribute | Value |
|---|---|
data-scope |
"inputtext" |
data-part |
"root" |
| Label | Type | Description |
|---|---|---|
| root | InputTextPassThroughType<InputHTMLAttributes> | Used to pass attributes to the root's DOM element. |
접근성 (Accessibility)
스크린 리더 (Screen Reader)
InputText는 네이티브 input 요소를 렌더링해요. 보이는 라벨, aria-label, 또는 aria-labelledby로 접근 가능한 이름을 제공해 주세요.
키보드 지원 (Keyboard Support)
InputText는 네이티브 텍스트 입력 키보드 동작을 사용해요.