input-otp
skeuomorph-krzysztof/input-otpFreeComponent
skeuomorph-krzysztof publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by skeuomorph-krzysztof on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://skeuomorph.krzysztof.studio/r/styles/new-york/input-otp.jsonSource
1"use client"23import * as React from "react"4import { OTPInput, OTPInputContext } from "input-otp"5import { Minus } from "lucide-react"67import { cn } from "@/lib/utils"89const InputOTP = React.forwardRef<10 React.ElementRef<typeof OTPInput>,11 React.ComponentPropsWithoutRef<typeof OTPInput>12>(({ className, containerClassName, ...props }, ref) => (13 <OTPInput14 ref={ref}15 containerClassName={cn(16 "flex items-center gap-2 has-[:disabled]:opacity-50",17 containerClassName18 )}19 className={cn("disabled:cursor-not-allowed", className)}20 {...props}21 />22))23InputOTP.displayName = "InputOTP"2425const InputOTPGroup = React.forwardRef<26 React.ElementRef<"div">,27 React.ComponentPropsWithoutRef<"div">28>(({ className, ...props }, ref) => (29 <div ref={ref} className={cn("flex items-center", className)} {...props} />30))31InputOTPGroup.displayName = "InputOTPGroup"3233const InputOTPSlot = React.forwardRef<34 React.ElementRef<"div">,35 React.ComponentPropsWithoutRef<"div"> & { index: number }36>(({ index, className, ...props }, ref) => {37 const inputOTPContext = React.useContext(OTPInputContext)38 const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index]3940 return (41 <div42 ref={ref}43 className={cn(44 "relative flex h-9 w-9 items-center justify-center border-y border-r border-input text-sm shadow-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md",45 isActive && "z-10 ring-1 ring-ring",46 className47 )}48 {...props}49 >50 {char}51 {hasFakeCaret && (52 <div className="pointer-events-none absolute inset-0 flex items-center justify-center">53 <div className="h-4 w-px animate-caret-blink bg-foreground duration-1000" />54 </div>55 )}56 </div>57 )58})59InputOTPSlot.displayName = "InputOTPSlot"6061const InputOTPSeparator = React.forwardRef<62 React.ElementRef<"div">,63 React.ComponentPropsWithoutRef<"div">64>(({ ...props }, ref) => (65 <div ref={ref} role="separator" {...props}>66 <Minus />67 </div>68))69InputOTPSeparator.displayName = "InputOTPSeparator"7071export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }
What it pulls in
npm packages
Files it writes
More from skeuomorph-krzysztof
All 54 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | skeuomorph-krzysztof | Components | Free | 1 dep | |
| alertalert | skeuomorph-krzysztof | Components | Free | no deps | |
| alert-dialogalert-dialog | skeuomorph-krzysztof | Components | Free | 1 dep | |
| aspect-ratioaspect-ratio | skeuomorph-krzysztof | Components | Free | 1 dep | |
| avataravatar | skeuomorph-krzysztof | Components | Free | 1 dep | |
| badgebadge | skeuomorph-krzysztof | Components | Free | 1 dep | |
| breadcrumbbreadcrumb | skeuomorph-krzysztof | Components | Free | 1 dep | |
| buttonbutton | skeuomorph-krzysztof | Components | Free | 1 dep |
