Introducing PrimeReact v11-alpha 🎉Discover Now
styledForm

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

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>

Examples#

Basic#

A one-time password input split into individual digit fields.

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

Custom#

Define a template with your own UI elements with bindings to the provided events and attributes to replace the default design.

custom-demo

Sample#

A sample UI implementation with templating and additional elements.

Authenticate Your Account

Please enter the code sent to your phone.

sample-demo

API#

Sub-Components#

See Primitive API for InputOtpRoot and InputOtpText component documentation.

Hooks#

See Headless API for useInputOtp hook documentation.

Accessibility#

See InputOtp Primitive for WAI-ARIA compliance details and keyboard support.