Introducing PrimeReact v11-alpha 🎉Discover Now

InputOtp

InputOtp is used to enter one time passwords.

Check your email for OTP
Please enter the 6-digit code sent to your email address to reset your password.
Didn't receive code?
preview

Installation#

npx shadcn@latest add @primereact/inputotp

Usage#

import { InputOtp, InputOtpText } from '@/components/ui/inputotp';
<InputOtp>
    <InputOtpText />
</InputOtp>

Examples#

Basic#

basic-demo

Controlled#

InputOtp can be used as a controlled component with value and onValueChange properties.

Value:
controlled-demo

Mask#

Enable the mask option to hide the values in the input fields.

mask-demo

Integer Only#

When integerOnly is present, only integers can be accepted as input.

integer-only-demo

Filled#

Specify the variant property as filled to display the component with a higher visual emphasis than the default outlined style.

filled-demo

Sizes#

InputOtp provides small and large sizes as alternatives to the base.

sizes-demo

Disabled#

When disabled is present, the component becomes non-interactive.

disabled-demo

Accessibility#

Screen Reader Support#

Input OTP uses a set of InputText components, refer to the InputText component for more information about the screen reader support.

Keyboard Support#

KeyFunction
tabMoves focus to the input otp.
right arrowMoves focus to the next input element.
left arrowMoves focus to the previous input element.
backspaceDeletes the input and moves focus to the previous input element.