Skip to content
VenusUI
Get started

Passcode Pad

A lock-screen passcode keypad that shakes on a wrong code and unlocks on the right one.

Preview

Installation

npx shadcn@latest add @venusui/passcode-pad

Run this in a project set up with shadcn. If you haven’t set it up yet, run npx shadcn@latest init first.

Files added to your project

Paths use the default shadcn aliases. The CLI follows the aliases in your components.json.

  • @/components/ui/passcode-pad.tsx

Usage

The code behind the preview above.

passcode-pad-demo.tsx

"use client"

import { PasscodePad } from "@/components/ui/passcode-pad"

export default function PasscodePadDemo() {
  return (
    <div className="flex flex-col items-center gap-6">
      <PasscodePad onSubmit={(code) => code === "2580"} />
      <p className="text-xs text-muted-foreground">Hint: the passcode is 2580</p>
    </div>
  )
}

API reference

PropTypeDefaultDescription
lengthnumber4Number of digits.
onSubmit(code: string) => boolean | Promise<boolean>—Checks a complete code; return true to unlock.
titlestring"Enter passcode"Heading above the dots.
successMessagestring"Unlocked"Shown once unlocked.

All <div> props.

Requirements

  • lucide-react for the lock icons. React 19 and Tailwind CSS v4.

Customization

  • Check codes on your server in onSubmit (it can be async); never ship the real code to the browser.

Accessibility

  • Keys are buttons named by digit; typing digits and Backspace also work.
  • Progress (“2 of 4 digits entered”) and the result are announced.

Troubleshooting

Typing digits does nothing.
Focus must be inside the pad (click a key or Tab into it) for the keyboard to reach it.
Unknown registry "@venusui"
Your shadcn CLI couldn’t find the namespace in the shadcn registry index. Use the latest CLI (npx shadcn@latest), install by URL, or register it with its address: npx shadcn@latest registry add @venusui=https://venusui.com/r/{name}.json.
No components.json found
Run npx shadcn@latest init in your project first.
Loading preview

A text field whose label sits inside and floats above on focus or when filled.

Loading preview

A number field with minus and plus buttons, clamped to a range.

Loading preview

OTP Input

Inputs

One-time code entry in separate boxes with paste, autofill and keyboard navigation.