Input Otp
uiable/input-otpFreeComponent
Input Otp component.
Live preview
live · rendered by the registry
Rendered by uiable on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://uiable.com/r/input-otp.jsonSource
1"use client";23import { ComponentProps, useContext } from "react";45import { OTPInput, OTPInputContext } from "input-otp";67import { cn } from "@/lib/utils";8import { MinusIcon } from "lucide-react";910function InputOTP({11 className,12 containerClassName,13 ...props14}: ComponentProps<typeof OTPInput> & {15 containerClassName?: string;16}) {17 return (18 <OTPInput19 data-slot="input-otp"20 containerClassName={cn(21 "cn-input-otp flex items-center has-disabled:opacity-50",22 containerClassName23 )}24 spellCheck={false}25 className={cn("disabled:cursor-not-allowed", className)}26 {...props}27 />28 );29}3031function InputOTPGroup({ className, ...props }: ComponentProps<"div">) {32 return (33 <div34 data-slot="input-otp-group"35 className={cn(36 "has-aria-invalid:ring-destructive/20 dark:has-aria-invalid:ring-destructive/40 has-aria-invalid:border-destructive flex items-center rounded-lg has-aria-invalid:ring-0",37 className38 )}39 {...props}40 />41 );42}4344function InputOTPSlot({45 index,46 className,47 ...props48}: ComponentProps<"div"> & {49 index: number;50}) {51 const inputOTPContext = useContext(OTPInputContext);52 const { char, hasFakeCaret, isActive } = inputOTPContext?.slots[index] ?? {};5354 return (55 <div56 data-slot="input-otp-slot"57 data-active={isActive}58 className={cn(59 "dark:bg-input/30 border-border data-[active=true]:border-border data-[active=true]:ring-input/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive relative flex size-10 items-center justify-center border-y border-r text-base transition-all outline-none first:rounded-l-lg first:border-l last:rounded-r-lg data-[active=true]:z-10 data-[active=true]:ring-0",60 className61 )}62 {...props}63 >64 {char}65 {hasFakeCaret && (66 <div className="pointer-events-none absolute inset-0 flex items-center justify-center">67 <div className="animate-caret-blink bg-foreground w-px duration-1000" />68 </div>69 )}70 </div>71 );72}7374function InputOTPSeparator({ ...props }: ComponentProps<"div">) {75 return (76 <div77 data-slot="input-otp-separator"78 className="flex items-center [&_svg:not([class*='size-'])]:size-4 px-1"79// … truncated
What it pulls in
npm packages
Files it writes
More from uiable
All 712 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | uiable | Components | Free | 2 deps | |
| Alertalert | uiable | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | uiable | Components | Free | 1 dep | |
| Aspect Ratioaspect-ratio | uiable | Components | Free | no deps | |
| Attachmentattachment | uiable | Components | Free | 2 deps | |
| Avataravatar | uiable | Components | Free | 1 dep | |
| Badgebadge | uiable | Components | Free | 2 deps | |
| Breadcrumbbreadcrumb | uiable | Components | Free | 2 deps |
