BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/solid-ui/otp-field

OTP Field

solid-ui/otp-field
FreeComponent

An OTP field component

Live preview

live · rendered by the registry
Rendered by solid-ui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://www.solid-ui.com/r/otp-field.json

Source

src/registry/ui/otp-field.tsxwww.solid-ui.com/r/otp-field.json
1import type { Component, ComponentProps, ValidComponent } from "solid-js"
2import { Show, splitProps } from "solid-js"
3
4import type { DynamicProps, RootProps } from "@corvu/otp-field"
5import OtpField from "@corvu/otp-field"
6
7import { cn } from "~/lib/utils"
8
9export const REGEXP_ONLY_DIGITS = "^\\d*$"
10export const REGEXP_ONLY_CHARS = "^[a-zA-Z]*$"
11export const REGEXP_ONLY_DIGITS_AND_CHARS = "^[a-zA-Z0-9]*$"
12
13type OTPFieldProps<T extends ValidComponent = "div"> = RootProps<T> & { class?: string }
14
15const OTPField = <T extends ValidComponent = "div">(props: DynamicProps<T, OTPFieldProps<T>>) => {
16 const [local, others] = splitProps(props as OTPFieldProps, ["class"])
17 return (
18 <OtpField
19 class={cn(
20 "flex items-center gap-2 disabled:cursor-not-allowed has-[:disabled]:opacity-50",
21 local.class
22 )}
23 {...others}
24 />
25 )
26}
27
28const OTPFieldInput = OtpField.Input
29
30const OTPFieldGroup: Component<ComponentProps<"div">> = (props) => {
31 const [local, others] = splitProps(props, ["class"])
32 return <div class={cn("flex items-center", local.class)} {...others} />
33}
34
35const OTPFieldSlot: Component<ComponentProps<"div"> & { index: number }> = (props) => {
36 const [local, others] = splitProps(props, ["class", "index"])
37 const context = OtpField.useContext()
38 const char = () => context.value()[local.index]
39 const showFakeCaret = () => context.value().length === local.index && context.isInserting()
40
41 return (
42 <div
43 class={cn(
44 "group relative flex size-10 items-center justify-center border-y border-r border-input text-sm first:rounded-l-md first:border-l last:rounded-r-md",
45 local.class
46 )}
47 {...others}
48 >
49 <div
50 class={cn(
51 "absolute inset-0 z-10 transition-all group-first:rounded-l-md group-last:rounded-r-md",
52 context.activeSlots().includes(local.index) && "ring-2 ring-ring ring-offset-background"
53 )}
54 />
55 {char()}
56 <Show when={showFakeCaret()}>
57 <div class="pointer-events-none absolute inset-0 flex items-center justify-center">
58 <div class="h-4 w-px animate-caret-blink bg-foreground duration-1000" />
59 </div>
60 </Show>
61 </div>
62 )
63}
64
65const OTPFieldSeparator: Component<ComponentProps<"div">> = (props) => {
66 return (
67 <div {...props}>
68 <svg
69 xmlns="http://www.w3.org/2000/svg"
70 viewBox="0 0 24 24"
71 fill="none"
72 stroke="currentColor"
73 stroke-width="2"
74// … truncated

What it pulls in

npm packages

  • solid-js
  • @corvu/otp-field

Files it writes

  • src/registry/ui/otp-field.tsx

Facts

Registry
solid-ui
Type
registry:ui
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-03
Last confirmed
yesterday

Go to the source

Docs on solid-ui www.solid-ui.com stefan-karger/solid-ui on GitHub Raw registry item This item as JSON

More from solid-ui

All 55 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Accordionaccordionsolid-uiComponentsFree2 deps
Alertalertsolid-uiComponentsFree3 deps
Alert Dialogalert-dialogsolid-uiComponentsFree2 deps
Aspect Ratioaspect-ratiosolid-uiComponentsFree1 dep
Avataravatarsolid-uiComponentsFree2 deps
Badgebadgesolid-uiComponentsFree2 deps
Badge Deltabadge-deltasolid-uiComponentsFree2 deps
Bar Listbar-listsolid-uiComponentsFree1 dep
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex