Home / File/ input-otp-demo.tsx — ui Source File

input-otp-demo.tsx — ui Source File

Architecture documentation for input-otp-demo.tsx, a tsx file in the ui codebase. 4 imports, 1 dependents.

File tsx DocumentationAtlas SearchAPI 4 imports 1 dependents 5 functions

Entity Profile

Dependency Diagram

graph LR
  1b6bdf38_9d26_f386_4da3_bbd14a0dfa28["input-otp-demo.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  1b6bdf38_9d26_f386_4da3_bbd14a0dfa28 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  46c758ca_dd64_66c4_37b9_b30acc3c853c["input-otp"]
  1b6bdf38_9d26_f386_4da3_bbd14a0dfa28 --> 46c758ca_dd64_66c4_37b9_b30acc3c853c
  5265f3fe_8cd8_5588_7be1_ffd3de687f74["input-otp"]
  1b6bdf38_9d26_f386_4da3_bbd14a0dfa28 --> 5265f3fe_8cd8_5588_7be1_ffd3de687f74
  d752035b_6ed3_c6ef_e27c_eef51af9ec8d["label"]
  1b6bdf38_9d26_f386_4da3_bbd14a0dfa28 --> d752035b_6ed3_c6ef_e27c_eef51af9ec8d
  1c2403dc_4584_9f39_4e98_855a7de18bd1["component-registry.ts"]
  1c2403dc_4584_9f39_4e98_855a7de18bd1 --> 1b6bdf38_9d26_f386_4da3_bbd14a0dfa28
  style 1b6bdf38_9d26_f386_4da3_bbd14a0dfa28 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import * as React from "react"
import { REGEXP_ONLY_DIGITS } from "input-otp"

import {
  InputOTP,
  InputOTPGroup,
  InputOTPSeparator,
  InputOTPSlot,
} from "@/registry/new-york-v4/ui/input-otp"
import { Label } from "@/registry/new-york-v4/ui/label"

export function InputOTPDemo() {
  return (
    <div className="flex flex-col flex-wrap gap-6 md:flex-row">
      <InputOTPSimple />
      <InputOTPPattern />
      <InputOTPWithSeparator />
      <InputOTPWithSpacing />
    </div>
  )
}

function InputOTPSimple() {
  return (
    <div className="grid gap-2">
      <Label htmlFor="simple">Simple</Label>
      <InputOTP id="simple" maxLength={6}>
        <InputOTPGroup>
          <InputOTPSlot index={0} />
          <InputOTPSlot index={1} />
          <InputOTPSlot index={2} />
        </InputOTPGroup>
        <InputOTPSeparator />
        <InputOTPGroup>
          <InputOTPSlot index={3} />
          <InputOTPSlot index={4} />
          <InputOTPSlot index={5} />
        </InputOTPGroup>
      </InputOTP>
    </div>
  )
}

function InputOTPPattern() {
  return (
    <div className="grid gap-2">
      <Label htmlFor="digits-only">Digits Only</Label>
      <InputOTP id="digits-only" maxLength={6} pattern={REGEXP_ONLY_DIGITS}>
        <InputOTPGroup>
          <InputOTPSlot index={0} />
          <InputOTPSlot index={1} />
          <InputOTPSlot index={2} />
          <InputOTPSlot index={3} />
          <InputOTPSlot index={4} />
          <InputOTPSlot index={5} />
        </InputOTPGroup>
      </InputOTP>
    </div>
  )
}

function InputOTPWithSeparator() {
  const [value, setValue] = React.useState("123456")

  return (
    <div className="grid gap-2">
      <Label htmlFor="with-separator">With Separator</Label>
      <InputOTP
        id="with-separator"
        maxLength={6}
        value={value}
        onChange={setValue}
      >
        <InputOTPGroup>
          <InputOTPSlot index={0} />
          <InputOTPSlot index={1} />
        </InputOTPGroup>
        <InputOTPSeparator />
        <InputOTPGroup>
          <InputOTPSlot index={2} />
          <InputOTPSlot index={3} />
        </InputOTPGroup>
        <InputOTPSeparator />
        <InputOTPGroup>
          <InputOTPSlot index={4} />
          <InputOTPSlot index={5} />
        </InputOTPGroup>
      </InputOTP>
    </div>
  )
}

function InputOTPWithSpacing() {
  return (
    <div className="grid gap-2">
      <Label htmlFor="with-spacing">With Spacing</Label>
      <InputOTP id="with-spacing" maxLength={6}>
        <InputOTPGroup className="gap-2 *:data-[slot=input-otp-slot]:rounded-md *:data-[slot=input-otp-slot]:border">
          <InputOTPSlot index={0} aria-invalid="true" />
          <InputOTPSlot index={1} aria-invalid="true" />
          <InputOTPSlot index={2} aria-invalid="true" />
          <InputOTPSlot index={3} aria-invalid="true" />
        </InputOTPGroup>
      </InputOTP>
    </div>
  )
}

Subdomains

Dependencies

  • input-otp
  • input-otp
  • label
  • react

Frequently Asked Questions

What does input-otp-demo.tsx do?
input-otp-demo.tsx is a source file in the ui codebase, written in tsx. It belongs to the DocumentationAtlas domain, SearchAPI subdomain.
What functions are defined in input-otp-demo.tsx?
input-otp-demo.tsx defines 5 function(s): InputOTPDemo, InputOTPPattern, InputOTPSimple, InputOTPWithSeparator, InputOTPWithSpacing.
What does input-otp-demo.tsx depend on?
input-otp-demo.tsx imports 4 module(s): input-otp, input-otp, label, react.
What files import input-otp-demo.tsx?
input-otp-demo.tsx is imported by 1 file(s): component-registry.ts.
Where is input-otp-demo.tsx in the architecture?
input-otp-demo.tsx is located at apps/v4/app/(internal)/sink/components/input-otp-demo.tsx (domain: DocumentationAtlas, subdomain: SearchAPI, directory: apps/v4/app/(internal)/sink/components).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free