{"$schema":"https://ui.shadcn.com/schema/registry-item.json","author":"Eduardo Calvo <edu@smoothui.dev>","css":{},"dependencies":["@base-ui/react"],"description":"OTP Field for SmoothUI with Base UI twin and Radix-parity twin for one-time codes.","devDependencies":[],"files":[{"content":"\"use client\";\n\nimport { OTPField as OTPFieldPrimitive } from \"@base-ui/react/otp-field\";\nimport { cn } from \"@/lib/utils\";\nimport type { ComponentProps, ReactNode } from \"react\";\nimport { useId } from \"react\";\n\nexport interface OTPFieldProps {\n  /** Accessible name when there is no visible `label` */\n  \"aria-label\"?: string;\n  /** Optional CSS class for the root */\n  className?: string;\n  /** Uncontrolled initial value */\n  defaultValue?: string;\n  /** Disable all slots */\n  disabled?: boolean;\n  /** Visible label above the slots */\n  label?: string;\n  /** Number of digit slots (default 6) */\n  length?: number;\n  /** Obscure characters (shared-screen friendly) */\n  mask?: boolean;\n  /** Form name */\n  name?: string;\n  /** Called when the OTP string changes */\n  onValueChange?: (value: string) => void;\n  /** Placeholder character for empty slots */\n  placeholder?: string;\n  /** Controlled value */\n  value?: string;\n}\n\nexport type OTPFieldRootProps = Omit<\n  ComponentProps<typeof OTPFieldPrimitive.Root>,\n  \"className\"\n> & { className?: string };\nexport type OTPFieldInputProps = Omit<\n  ComponentProps<typeof OTPFieldPrimitive.Input>,\n  \"className\"\n> & { className?: string };\n\nconst SLOT_CLASS =\n  \"m-0 size-10 shrink-0 rounded-md border border-foreground/25 bg-background text-center font-medium text-base md:text-sm tabular-nums outline-none state-transition placeholder:text-muted-foreground/50 focus-visible:border-ring focus-ring disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground data-disabled:cursor-not-allowed data-disabled:bg-muted\";\n\nexport const OTPFieldRoot = ({ className, ...props }: OTPFieldRootProps) => (\n  <OTPFieldPrimitive.Root\n    className={cn(\"flex w-full gap-2\", className)}\n    data-slot=\"otp-field\"\n    {...props}\n  />\n);\n\nexport const OTPFieldInput = ({ className, ...props }: OTPFieldInputProps) => (\n  <OTPFieldPrimitive.Input\n    className={cn(SLOT_CLASS, className)}\n    data-slot=\"otp-field-input\"\n    {...props}\n  />\n);\n\n/**\n * SmoothUI OTP Field — Base UI twin (default).\n * Convenience API that renders `length` digit slots.\n */\nexport default function OTPField({\n  \"aria-label\": ariaLabel,\n  className,\n  defaultValue,\n  disabled,\n  label,\n  length = 6,\n  mask = false,\n  name,\n  onValueChange,\n  placeholder = \"•\",\n  value,\n}: OTPFieldProps) {\n  const id = useId();\n  const slots: ReactNode[] = [];\n\n  for (let index = 0; index < length; index += 1) {\n    slots.push(\n      <OTPFieldInput\n        aria-label={\n          index === 0 ? undefined : `Character ${index + 1} of ${length}`\n        }\n        disabled={disabled}\n        key={index}\n        placeholder={placeholder}\n      />\n    );\n  }\n\n  return (\n    <div className={cn(\"flex flex-col items-start gap-1.5\", className)}>\n      {label ? (\n        <label className=\"font-medium text-sm leading-none\" htmlFor={id}>\n          {label}\n        </label>\n      ) : null}\n      <OTPFieldRoot\n        aria-label={label ? undefined : ariaLabel}\n        defaultValue={defaultValue}\n        disabled={disabled}\n        id={id}\n        length={length}\n        mask={mask}\n        name={name}\n        onValueChange={(next) => {\n          onValueChange?.(next);\n        }}\n        value={value}\n      >\n        {slots}\n      </OTPFieldRoot>\n    </div>\n  );\n}\n","path":"index.tsx","target":"components/smoothui/otp-field/index.tsx","type":"registry:ui"}],"name":"otp-field","registryDependencies":["https://smoothui.dev/r/tokens.json"],"title":"Otp Field","type":"registry:ui"}