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

InputOtp — 일회용 비밀번호(OTP)를 입력하는 컴포넌트

원문 보기 위키 갱신

InputOtp는 일회용 비밀번호(one-time password)를 입력할 때 쓰는 컴포넌트예요. 숫자 한 자리씩 나뉘어 입력받아 OTP 인증 UI를 손쉽게 만들 수 있어요.

출처: 문서

본문

InputOtp는 일회용 비밀번호(one time password)를 입력할 때 사용해요.

사용법 (Usage)

import { InputOtp } from '@primereact/ui/inputotp';
<InputOtp.Root>
    <InputOtp.Text index={0} />
    <InputOtp.Text index={1} />
    <InputOtp.Text index={2} />
    <InputOtp.Text index={3} />
</InputOtp.Root>

예시

기본 (Basic)

개별 숫자 필드로 나뉜 일회용 비밀번호 입력이에요.

제어 (Controlled)

InputOtp는 value와 onValueChange 속성으로 제어되는 컴포넌트로 사용할 수 있어요.

마스크 (Mask)

mask 옵션을 활성화하면 입력 필드에 입력된 값을 숨겨요.

정수만 (Integer Only)

integerOnly가 있으면 입력으로 정수만 받을 수 있어요.

채움 (Filled)

variant 속성을 filled로 지정하면 기본 outlined 스타일보다 시각적 강조가 높은 컴포넌트로 표시돼요.

크기 (Sizes)

InputOtp는 기본 크기 대신 small과 large 크기를 제공해요.

비활성화 (Disabled)

disabled가 있으면 컴포넌트는 상호작용할 수 없게 돼요.

커스텀 (Custom)

제공되는 이벤트와 속성에 바인딩한 나만의 UI 요소로 템플릿을 정의해 기본 디자인을 대체할 수 있어요.

샘플 (Sample)

템플릿과 추가 요소를 사용한 샘플 UI 구현이에요.

관련 자료

하위 컴포넌트 (Sub-Components)

InputOtpRoot, InputOtpText 컴포넌트 문서는 Primitive API에서 확인할 수 있어요.

훅 (Hooks)

useInputOtp 훅 문서는 Headless API에서 확인할 수 있어요.

접근성 (Accessibility)

WAI-ARIA 준수 사항과 키보드 지원에 대한 자세한 내용은 InputOtp Primitive에서 볼 수 있어요.

테마 (Theming)

CSS 클래스 (CSS Classes)

styled 모드에서 사용하는 클래스 이름 목록이에요.

ClassName Description
p-inputotp Class name of the root element
p-inputotp-input Class name of the input element

디자인 토큰 (Design Tokens)

디자인 토큰 목록이에요.

Token CSS Variable Description
inputotp.gap --p-inputotp-gap Gap of root
inputotp.input.width --p-inputotp-input-width Width of input
inputotp.input.sm.width --p-inputotp-input-sm-width Width of input in small screens
inputotp.input.lg.width --p-inputotp-input-lg-width Width of input in large screens

더 알아보기 (Learn more)