Input OTP 3

PreviousNext

A 4-digit OTP input field with resend functionality and helper text

Docs
shadcn-studiocomponent

Preview

Loading preview…
registry/new-york/components/input-otp/input-otp-03.tsx
import { useId } from 'react'

import { InputOTP, InputOTPGroup, InputOTPSlot } from '@/registry/new-york/ui/input-otp'
import { Label } from '@/registry/new-york/ui/label'

const InputOTPWithResendDemo = () => {
  const id = useId()

  return (
    <div className='space-y-3'>
      <Label htmlFor={id}>Input OTP with resend</Label>
      <InputOTP id={id} maxLength={4}>
        <InputOTPGroup>
          <InputOTPSlot index={0} />
          <InputOTPSlot index={1} />
          <InputOTPSlot index={2} />
          <InputOTPSlot index={3} />
        </InputOTPGroup>
      </InputOTP>
      <p className='text-muted-foreground text-xs'>
        Didn&apos;t get the code?{' '}
        <a href='#' className='text-primary hover:underline'>
          Resend code
        </a>
      </p>
    </div>
  )
}

export default InputOTPWithResendDemo

Installation

npx shadcn@latest add @shadcn-studio/input-otp-03

Usage

import { InputOtp03 } from "@/components/input-otp-03"
<InputOtp03 />