Core

PIN Input

Masked access-code input (PIN or passphrase) with paste support and accessible loading/error states.

coreform

Best used for Building a custom access-code form on useKnockCodes without adopting a full template's layout.

The presentational primitive <KnockCodes> and every dialog-based block render internally. Independently useful any time you're building a fully custom access-code form on top of the headless useKnockCodes hook.

Loading preview…
Installation

Add this block to your project

CLI

npx shadcn@latest add http://localhost:3000/r/react/pin-input.json

Running this site somewhere other than localhost? Set NEXT_PUBLIC_SITE_URL and this command switches to that host automatically.

Also installs

  • Knock Codes Core
  • Knock Codes Types

Files created (6)

  • components/knock-codes/core/hash.ts
  • components/knock-codes/core/verify.ts
  • components/knock-codes/core/session.ts
  • components/knock-codes/core/storage.ts
  • components/knock-codes/react/types.ts
  • components/knock-codes/react/PinInput.tsx

No CLI? Copy the files by hand

  1. Open the Code tab in the preview above.
  2. Create each path listed below in your project and paste its contents in.
  3. Do the same for anything listed under “Also installs”, if present.

Props

API reference

PropTypeDefaultDescription
value *stringCurrent input value (controlled).
onChange *(value: string) => voidCalled on every keystroke/paste.
onSubmit *() => voidCalled on Enter or the submit button, when not empty and not submitting.
submitting *booleanDisables the field and shows the busy label.
error *KnockCodesError | nullDrives which error message renders in the status region.
labelsKnockCodesLabelsOverrides for every user-facing string.
autoFocusbooleanFocus the field on mount.
Notes

Accessibility

Labeled via a real <label>, not just a placeholder. The show/hide toggle is a real button with an aria-label that flips with its state. Errors and the submitting label live in a shared aria-live="polite" region.

Customization

Deliberately a single masked text field, not a segmented per-character box grid — that shape supports arbitrary-length passphrases, not just 4-6 digit PINs. It carries no verification logic of its own, so it drops into any custom gate UI built on `useKnockCodes`.

Compose with

Blocks that pair well with this one

These combine naturally with this block, whether as a shared shell, a shared session, or a common fallback.