Input Otp Controlled

PreviousNext

input-otp-controlled-demo

Docs
intentuipage

Preview

Loading preview…
components/docs/forms/input-otp/input-otp-controlled-demo.tsx
"use client"

import { useState } from "react"
import { Description } from "@/components/ui/field"
import { InputOTP, InputOTPControl, InputOTPGroup, InputOTPSlot } from "@/components/ui/input-otp"

export default function InputOtpControlledDemo() {
  const [value, setValue] = useState("")
  return (
    <InputOTP maxLength={6} value={value} onChange={setValue}>
      <InputOTPControl>
        <InputOTPGroup>
          {[...Array(6)].map((_, index) => (
            <InputOTPSlot key={index} index={index} />
          ))}
        </InputOTPGroup>
      </InputOTPControl>
      <Description>
        {value === "" ? "Enter your one-time password." : `Your one-time password is: ${value}`}
      </Description>
    </InputOTP>
  )
}

Installation

npx shadcn@latest add @intentui/input-otp-controlled-demo

Usage

Usage varies by registry entry. Refer to the registry docs or source files below for details.