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

InputPassword

원문 보기 위키 갱신

마스크 토글과 제어/비제어 값 상태를 지원하는, 스타일 없는 비밀번호 입력 컴포넌트예요.

출처: 문서

본문

기능 (Features)

  • 표시 여부 제어를 위한 password ↔ text 입력 타입 동적 토글
  • 값과 마스크 상태 모두에 대한 제어/비제어 모드
  • 프로그래밍 방식 마스크 전환을 위한 인스턴스 메서드 toggleMask()

사용법 (Usage)

import { InputPassword } from 'primereact/inputpassword';
<InputPassword />

동작 (Behavior)

다형적 렌더링 (Polymorphic Rendering)

as를 사용해 렌더링할 입력 요소를 바꿀 수 있어요.

<InputPassword as="input" />

렌더 함수 자식 (Render Function Children)

InputPassword는 컴포넌트 인스턴스에 접근할 수 있는 렌더 함수를 children으로 받아요.

<InputPassword>{(instance) => <span>{instance.state.mask ? 'Hidden' : 'Visible'}</span>}</InputPassword>

Pass Through

<DocPTViewer name="inputpassword-pt" components={['InputPassword']} />

API

InputPassword

Attribute Value
data-scope "password"
data-part "root"
Label Type Description
root InputPasswordPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

접근성 (Accessibility)

스크린 리더 (Screen Reader)

컴포넌트를 설명할 값은 id prop과 결합된 label 태그, 또는 aria-labelledby, aria-label prop으로 제공할 수 있어요. 타이핑하는 동안 aria-live가 있는 섹션을 통해 비밀번호 강도 변화를 스크린 리더에 알려줘요.

키보드 지원 (Keyboard Support)

Key Function
tab Moves focus to the input.

더 알아보기 (Learn more)