Glass Input OTP
washiveil/glass-input-otpFreeComponent
One-time-code input on glass cells with a ruri active caret.
Install it
npx shadcn@latest add https://washiveil.alexchih.com/r/glass-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 GlassInputOTP = React.forwardRef<10 React.ComponentRef<typeof OTPInput>,11 React.ComponentPropsWithoutRef<typeof OTPInput>12>(({ className, containerClassName, ...props }, ref) => (13 <OTPInput14 ref={ref}15 containerClassName={cn('flex items-center gap-2 has-[:disabled]:opacity-50', containerClassName)}16 className={cn('disabled:cursor-not-allowed', className)}17 {...props}18 />19))20GlassInputOTP.displayName = 'GlassInputOTP'2122function GlassInputOTPGroup({ className, ...props }: React.ComponentProps<'div'>) {23 return <div className={cn('flex items-center gap-1.5', className)} {...props} />24}25GlassInputOTPGroup.displayName = 'GlassInputOTPGroup'2627function GlassInputOTPSlot({28 index,29 className,30 ...props31}: React.ComponentProps<'div'> & { index: number }) {32 const inputOTPContext = React.useContext(OTPInputContext)33 const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index]3435 return (36 <div37 className={cn(38 'relative flex size-10 items-center justify-center rounded-xl border border-border bg-glass font-mono text-sm backdrop-blur-md transition-all',39 isActive && 'z-10 outline-none ring-2 ring-ring ring-offset-2 ring-offset-background',40 className,41 )}42 {...props}43 >44 {char}45 {hasFakeCaret && (46 <div className="pointer-events-none absolute inset-0 flex items-center justify-center">47 <div className="h-4 w-px animate-caret-blink bg-foreground motion-reduce:animate-none" />48 </div>49 )}50 </div>51 )52}53GlassInputOTPSlot.displayName = 'GlassInputOTPSlot'5455function GlassInputOTPSeparator({ ...props }: React.ComponentProps<'div'>) {56 return (57 <div role="separator" {...props}>58 <Minus className="size-3.5 text-faint" />59 </div>60 )61}62GlassInputOTPSeparator.displayName = 'GlassInputOTPSeparator'6364export { GlassInputOTP, GlassInputOTPGroup, GlassInputOTPSlot, GlassInputOTPSeparator }
What it pulls in
npm packages
Other registry items
Files it writes
More from washiveil
All 58 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Ambient Fieldambient-field | washiveil | Components | Free | no deps | |
| Chipchip | washiveil | Components | Free | 1 dep | |
| Code Badgecode-badge | washiveil | Components | Free | no deps | |
| Glass Accordionglass-accordion | washiveil | Components | Free | 2 deps | |
| Glass Alertglass-alert | washiveil | Components | Free | 1 dep | |
| Glass Alert Dialogglass-alert-dialog | washiveil | Components | Free | 1 dep | |
| Glass Aspect Ratioglass-aspect-ratio | washiveil | Components | Free | 1 dep | |
| Glass Avatarglass-avatar | washiveil | Components | Free | 1 dep |
