126 lines
2.9 KiB
TypeScript
126 lines
2.9 KiB
TypeScript
|
|
export const basicOtp=`import {
|
||
|
|
InputOTP,
|
||
|
|
InputOTPGroup,
|
||
|
|
InputOTPSeparator,
|
||
|
|
InputOTPSlot,
|
||
|
|
} from "@/components/ui/input-otp";
|
||
|
|
|
||
|
|
const BasicInput = () => {
|
||
|
|
return (
|
||
|
|
<div className="flex justify-center">
|
||
|
|
<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>
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
};
|
||
|
|
|
||
|
|
export default BasicInput;`
|
||
|
|
|
||
|
|
export const patternOtp=`"use client"
|
||
|
|
import { REGEXP_ONLY_DIGITS_AND_CHARS } from "input-otp"
|
||
|
|
|
||
|
|
import {
|
||
|
|
InputOTP,
|
||
|
|
InputOTPGroup,
|
||
|
|
InputOTPSlot,
|
||
|
|
} from "@/components/ui/input-otp"
|
||
|
|
const PatternOtp = () => {
|
||
|
|
return (
|
||
|
|
<div className="flex justify-center">
|
||
|
|
<InputOTP maxLength={6} pattern={REGEXP_ONLY_DIGITS_AND_CHARS}>
|
||
|
|
<InputOTPGroup>
|
||
|
|
<InputOTPSlot index={0} />
|
||
|
|
<InputOTPSlot index={1} />
|
||
|
|
<InputOTPSlot index={2} />
|
||
|
|
<InputOTPSlot index={3} />
|
||
|
|
<InputOTPSlot index={4} />
|
||
|
|
<InputOTPSlot index={5} />
|
||
|
|
</InputOTPGroup>
|
||
|
|
</InputOTP>
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
};
|
||
|
|
|
||
|
|
export default PatternOtp;`
|
||
|
|
|
||
|
|
export const separatorOtp=`
|
||
|
|
import {
|
||
|
|
InputOTP,
|
||
|
|
InputOTPGroup,
|
||
|
|
InputOTPSeparator,
|
||
|
|
InputOTPSlot,
|
||
|
|
} from "@/components/ui/input-otp"
|
||
|
|
const SeperatorOtp = () => {
|
||
|
|
return (
|
||
|
|
<div className="flex justify-center">
|
||
|
|
<InputOTP maxLength={6} >
|
||
|
|
<InputOTPGroup>
|
||
|
|
<InputOTPSlot index={0} />
|
||
|
|
<InputOTPSlot index={1} />
|
||
|
|
</InputOTPGroup>
|
||
|
|
<InputOTPSeparator />
|
||
|
|
<InputOTPGroup>
|
||
|
|
<InputOTPSlot index={2} />
|
||
|
|
<InputOTPSlot index={3} />
|
||
|
|
</InputOTPGroup>
|
||
|
|
<InputOTPSeparator />
|
||
|
|
<InputOTPGroup>
|
||
|
|
<InputOTPSlot index={4} />
|
||
|
|
<InputOTPSlot index={5} />
|
||
|
|
</InputOTPGroup>
|
||
|
|
</InputOTP >
|
||
|
|
</div>
|
||
|
|
)
|
||
|
|
};
|
||
|
|
|
||
|
|
export default SeperatorOtp;`
|
||
|
|
|
||
|
|
export const controlledOtp=`"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;`
|