Components/Input OTP
Binhlaig UI Component

Input OTP

An accessible one-time password input for verification codes, login flows and security confirmations.

Installation

Add Input OTP to your project using the Binhlaig UI CLI.

Terminal
npx binhlaig-ui@latest add input-otp

Import

Import the OTP components from your UI directory.

TypeScript
import {
  InputOTP,
  InputOTPGroup,
  InputOTPSeparator,
  InputOTPSlot,
} from "@/components/ui/input-otp";

Usage

Create a basic six-character verification input.

Numeric OTP

Restrict OTP input to numbers only.

With Separator

Split the OTP into groups using a separator.

Controlled OTP

Control the OTP value using React state.

Current valueEmpty

Verification Card

Use Input OTP in an email or account verification flow.

Verify your email

Enter the 6-digit verification code sent to your email address.

Disabled State

Disable the OTP input when users should not edit the value.

Error State

Display a validation message when the OTP is incorrect.

The verification code is incorrect.

API Reference

Components and important properties available in Input OTP.

ComponentImportant PropsDescription
InputOTPmaxLength, value, onChange, pattern, disabledThe root OTP input component.
InputOTPGroupclassNameGroups related OTP slots together.
InputOTPSlotindex, classNameDisplays one character of the OTP value.
InputOTPSeparatorclassNameDisplays a visual separator between OTP groups.