38 lines
904 B
TypeScript
38 lines
904 B
TypeScript
"use client"
|
|
import {
|
|
InputOTP,
|
|
InputOTPGroup,
|
|
InputOTPSlot,
|
|
} from "@/components/ui/input-otp"
|
|
import { useState } from "react";
|
|
const ControlledOtp = () => {
|
|
const [value, setValue] = useState("")
|
|
|
|
return (
|
|
<div className="flex flex-col items-center gap-4">
|
|
<InputOTP
|
|
maxLength={6}
|
|
value={value}
|
|
onChange={(value) => setValue(value)}
|
|
>
|
|
<InputOTPGroup>
|
|
<InputOTPSlot index={0} />
|
|
<InputOTPSlot index={1} />
|
|
<InputOTPSlot index={2} />
|
|
<InputOTPSlot index={3} />
|
|
<InputOTPSlot index={4} />
|
|
<InputOTPSlot index={5} />
|
|
</InputOTPGroup>
|
|
</InputOTP>
|
|
<div className=" text-sm">
|
|
{value === "" ? (
|
|
<>Enter your one-time password.</>
|
|
) : (
|
|
<>You entered: {value}</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default ControlledOtp; |