BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/@zard/input-otp

input-otp

zard/input-otp
FreeComponent

@zard publishes no description for this item.

Live preview

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

Install it

npx shadcn@latest add https://www.zardui.com/r/input-otp.json

Source

input-otp.component.tswww.zardui.com/r/input-otp.json · first 6 KB
1import {
2 type AfterContentInit,
3 afterNextRender,
4 booleanAttribute,
5 ChangeDetectionStrategy,
6 Component,
7 computed,
8 contentChildren,
9 type ElementRef,
10 forwardRef,
11 inject,
12 Injector,
13 input,
14 output,
15 signal,
16 ViewEncapsulation,
17 viewChildren,
18} from '@angular/core';
19import { type ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
20
21import type { ClassValue } from 'clsx';
22
23import { mergeClasses } from '@/shared/utils/merge-classes';
24
25import { ZARD_INPUT_OTP_SLOT, type ZardInputOtpSlotApi } from './input-otp.tokens';
26import { isInputElement, isInputEvent } from './input-otp.utils';
27import { inputOtpSlotVariants, inputOtpVariants, type ZardInputOtpSize } from './input-otp.variants';
28
29type OnTouchedType = () => void;
30type OnChangeType = (value: string) => void;
31
32@Component({
33 selector: 'z-input-otp, [z-input-otp]',
34 template: `
35 <div [class]="classes()" [attr.data-input-otp-container]="''">
36 @if (!hasSlots()) {
37 @for (i of range(); track i) {
38 <input
39 #otpInput
40 type="text"
41 [value]="tokens()[i - 1] || ''"
42 [attr.maxlength]="1"
43 [attr.inputmode]="inputMode()"
44 [attr.autocomplete]="'one-time-code'"
45 [attr.aria-label]="ariaLabel(i)"
46 [attr.aria-invalid]="zInvalid() ? 'true' : null"
47 [attr.data-active]="allSelected() ? '' : null"
48 [disabled]="disabled()"
49 [readonly]="zReadonly()"
50 [class]="slotClasses(i - 1)"
51 (input)="onInput($event, i - 1)"
52 (focus)="onInputFocus($event, i - 1)"
53 (blur)="onInputBlur()"
54 (paste)="onPaste($event)"
55 (keydown)="onKeyDown($event)"
56 />
57 }
58 }
59 <ng-content />
60 </div>
61 `,
62 providers: [
63 {
64 provide: NG_VALUE_ACCESSOR,
65 useExisting: forwardRef(() => ZardInputOtpComponent),
66 multi: true,
67 },
68 ],
69 changeDetection: ChangeDetectionStrategy.OnPush,
70 encapsulation: ViewEncapsulation.None,
71 host: {
72 '[attr.data-slot]': '"input-otp"',
73 '[attr.data-disabled]': 'disabled() ? "" : null',
74 '(copy)': 'onCopy($event)',
75 '(cut)': 'onCut($event)',
76 '(mousedown)': 'clearSelectAll()',
77 },
78})
79export class ZardInputOtpComponent implements ControlValueAccessor, AfterContentInit {
80 readonly inputs = viewChildren<ElementRef<HTMLInputElement>>('otpInput');
81
82 readonly zMaxLength = input<number | undefined>(undefined);
83// … truncated

Files it writes

  • input-otp.component.ts
  • input-otp-signal.component.ts
  • input-otp-slot.component.ts
  • input-otp-group.component.ts
  • input-otp-separator.component.ts
  • input-otp.imports.ts
  • input-otp.tokens.ts
  • input-otp.utils.ts
  • input-otp.variants.ts
  • index.ts

Facts

Registry
@zard
Type
registry:component
Access
Free
Files written
10
Licence
MIT
First indexed
2026-08-06
Last confirmed
today

Go to the source

Docs on @zard www.zardui.com zard-ui/zardui on GitHub Raw registry item This item as JSON

More from @zard

All 49 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
accordionaccordion@zardComponentsFreeno deps · 5 files
alertalert@zardComponentsFreeno deps · 3 files
alert-dialogalert-dialog@zardComponentsFreeno deps · 5 files
avataravatar@zardComponentsFreeno deps · 4 files
badgebadge@zardComponentsFreeno deps · 3 files
breadcrumbbreadcrumb@zardComponentsFreeno deps · 4 files
buttonbutton@zardComponentsFreeno deps · 3 files
button-groupbutton-group@zardComponentsFreeno deps · 3 files
BlockDex

Built by

Kynth Studios

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 Studios

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 Studios

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