UILab

Input OTP

Accessible one-time password component with copy paste functionality.

1
2
3
4
5
6
import {
  InputOTP,
  InputOTPGroup,
  InputOTPSlot,
} from "uilab-core"

Usage

import {
  InputOTP,
  InputOTPGroup,
  InputOTPSeparator,
  InputOTPSlot,
} from "@/components/ui/input-otp"
<InputOTP maxLength={6}>
  <InputOTPGroup>
    <InputOTPSlot index={0} />
    <InputOTPSlot index={1} />
    <InputOTPSlot index={2} />
  </InputOTPGroup>
  <InputOTPSeparator />
  <InputOTPGroup>
    <InputOTPSlot index={3} />
    <InputOTPSlot index={4} />
    <InputOTPSlot index={5} />
  </InputOTPGroup>
</InputOTP>

Examples

Separator

Use the <InputOTPSeparator /> component to add a separator between input groups.

"use client"

import {
  InputOTP,
  InputOTPGroup,

Disabled

Use the disabled prop to disable the input.

1
2
3
4
5
6
"use client"

import * as React from "react"
import {
  InputOTP,

Controlled

Use the value and onChange props to control the input value.

Enter your one-time password.
"use client"

import * as React from "react"
import {
  InputOTP,

Invalid

Use aria-invalid on the slots to show an error state.

0
0
0
0
0
0
"use client"

import * as React from "react"
import {
  InputOTP,

Form

Verify your login
Enter the verification code we sent to your email address: m@example.com.

I no longer have access to this email address.

Having trouble signing in? Contact support
"use client"

import {
  Button,
  Card,

On this page