Input OTP
boldkit/input-otpFreeComponent
One-time password input with neubrutalism styling
Live preview
live · rendered by the registry
Rendered by boldkit on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://boldkit.dev/r/input-otp.jsonSource
1import * as React from 'react'2import { OTPInput, OTPInputContext } from 'input-otp'3import { Dot } from 'lucide-react'4import { cn } from '@/lib/utils'56const InputOTP = React.forwardRef<7 React.ElementRef<typeof OTPInput>,8 React.ComponentPropsWithoutRef<typeof OTPInput>9>(({ className, containerClassName, ...props }, ref) => (10 <OTPInput11 ref={ref}12 containerClassName={cn(13 'flex items-center gap-2 has-[:disabled]:opacity-50',14 containerClassName15 )}16 className={cn('disabled:cursor-not-allowed', className)}17 {...props}18 />19))20InputOTP.displayName = 'InputOTP'2122const InputOTPGroup = React.forwardRef<23 React.ElementRef<'div'>,24 React.ComponentPropsWithoutRef<'div'>25>(({ className, ...props }, ref) => (26 <div ref={ref} className={cn('flex items-center', className)} {...props} />27))28InputOTPGroup.displayName = 'InputOTPGroup'2930const InputOTPSlot = React.forwardRef<31 React.ElementRef<'div'>,32 React.ComponentPropsWithoutRef<'div'> & { index: number }33>(({ index, className, ...props }, ref) => {34 const inputOTPContext = React.useContext(OTPInputContext)35 const slot = inputOTPContext.slots?.[index] ?? { char: null, hasFakeCaret: false, isActive: false }36 const { char, hasFakeCaret, isActive } = slot3738 return (39 <div40 ref={ref}41 className={cn(42 'relative flex h-12 w-12 items-center justify-center border-3 border-foreground bg-background text-sm font-bold uppercase shadow-[4px_4px_0px_hsl(var(--shadow-color))] transition duration-200',43 isActive && 'z-10 ring-2 ring-ring ring-offset-background translate-x-[4px] translate-y-[4px] shadow-none',44 className45 )}46 {...props}47 >48 {char}49 {hasFakeCaret && (50 <div className="pointer-events-none absolute inset-0 flex items-center justify-center">51 <div className="h-6 w-px animate-caret-blink bg-foreground duration-1000" />52 </div>53 )}54 </div>55 )56})57InputOTPSlot.displayName = 'InputOTPSlot'5859const InputOTPSeparator = React.forwardRef<60 React.ElementRef<'div'>,61 React.ComponentPropsWithoutRef<'div'>62>(({ ...props }, ref) => (63 <div ref={ref} role="separator" {...props}>64 <Dot className="h-4 w-4" />65 </div>66))67InputOTPSeparator.displayName = 'InputOTPSeparator'6869export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }
What it pulls in
npm packages
Other registry items
Files it writes
More from boldkit
All 94 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | boldkit | Components | Free | 2 deps | |
| Alertalert | boldkit | Components | Free | 2 deps | |
| Alert Dialogalert-dialog | boldkit | Components | Free | 1 dep | |
| ASCII Shapesascii-shapes | boldkit | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | boldkit | Components | Free | 1 dep | |
| Avataravatar | boldkit | Components | Free | 1 dep | |
| Badgebadge | boldkit | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | boldkit | Components | Free | 2 deps |
