input-otp
9ui/input-otpFreeComponent
9ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by 9ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://9ui.dev/r/input-otp.jsonSource
1"use client"23import * as React from "react"4import { OTPInput, OTPInputContext } from "input-otp"5import { MinusIcon } from "lucide-react"67import { cn } from "@/lib/utils"89function InputOTP({10 className,11 containerClassName,12 ...props13}: React.ComponentProps<typeof OTPInput> & {14 containerClassName?: string15}) {16 return (17 <OTPInput18 data-slot="input-otp"19 containerClassName={cn(20 "flex items-center gap-2 has-disabled:opacity-50",21 containerClassName22 )}23 className={cn("disabled:pointer-events-none", className)}24 {...props}25 />26 )27}2829function InputOTPGroup({ className, ...props }: React.ComponentProps<"div">) {30 return (31 <div32 data-slot="input-otp-group"33 className={cn("flex items-center", className)}34 {...props}35 />36 )37}3839function InputOTPSlot({40 index,41 className,42 ...props43}: React.ComponentProps<"div"> & {44 index: number45}) {46 const inputOTPContext = React.useContext(OTPInputContext)47 const { char, hasFakeCaret, isActive } = inputOTPContext?.slots[index] ?? {}4849 return (50 <div51 data-slot="input-otp-slot"52 data-active={isActive}53 className={cn(54 "data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/50 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive bg-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]",55 className56 )}57 {...props}58 >59 {char}60 {hasFakeCaret && (61 <div className="pointer-events-none absolute inset-0 flex items-center justify-center">62 <div className="animate-caret-blink bg-foreground h-4 w-px duration-1000" />63 </div>64 )}65 </div>66 )67}6869function InputOTPSeparator({70 children,71 ...props72}: React.ComponentProps<"div">) {73 return (74 <div data-slot="input-otp-separator" role="separator" {...props}>75 {children || <MinusIcon />}76 </div>77 )78}7980export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }
What it pulls in
npm packages
Files it writes
More from 9ui
All 56 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | 9ui | Components | Free | no deps | |
| alertalert | 9ui | Components | Free | no deps | |
| alert-dialogalert-dialog | 9ui | Components | Free | no deps | |
| aspect-ratioaspect-ratio | 9ui | Components | Free | no deps | |
| autocompleteautocomplete | 9ui | Components | Free | no deps | |
| avataravatar | 9ui | Components | Free | no deps | |
| badgebadge | 9ui | Components | Free | no deps | |
| breadcrumbsbreadcrumbs | 9ui | Components | Free | no deps |
