Componentticket-stub3.78 KB gzipZero dependencies

Keypad

Numeric PIN keypad with tactile mechanical keys, visual pulse, and masked PIN display.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add keypad

Or install the full npm package:

npm install bigbullui

Usage

tsx10 lines
import { Keypad } from "@/components/ui/keypad"; <Keypad  maxLength={4}  title="BOX OFFICE TURNSTILE"  terminalId="TERMINAL #07"  gate="GATE A-01"  onValueChange={(pin) => console.log(pin)}  onSubmit={(pin) => console.log("Admitted PIN:", pin)}/>

Source code

keypad.tsx + 1 helper

Zero third-party dependencies (2 local files shown in tabs below).

tsxkeypad.tsx601 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface KeypadProps  extends Omit<React.HTMLAttributes<HTMLDivElement>, "onSubmit" | "defaultValue"> {  /** Maximum length of the PIN code (default: 4) */  maxLength?: number;  /** Controlled PIN value */  value?: string;  /** Default initial PIN value for uncontrolled mode */  defaultValue?: string;  /** Callback fired whenever the entered PIN value changes */  onValueChange?: (pin: string) => void;  /** Callback fired when ENTER is pressed or PIN reaches maxLength */  onSubmit?: (pin: string) => void;  /** Callback fired when CLEAR is pressed */

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { Keypad } from "@/components/ui/keypad"; <Keypad />
PropTypeDescription
maxLengthnumberMaximum length of the PIN code (default: 4)
valuestringControlled PIN value
defaultValuestringDefault initial PIN value for uncontrolled mode
onValueChange(pin: string) => voidCallback fired whenever the entered PIN value changes
onSubmit(pin: string) => voidCallback fired when ENTER is pressed or PIN reaches maxLength
onClear() => voidCallback fired when CLEAR is pressed
maskedbooleanWhether the PIN digits are masked (default: true)
allowMaskTogglebooleanWhether to show a toggle button to reveal/mask the PIN (default: true)
enableSoundbooleanWhether to synthesize tactile mechanical key click audio via Web Audio API (default: true)
disabledbooleanWhether all keypad inputs are disabled
status"idle" | "validating" | "success" | "error"Turnstile security validation status
statusMessagestringCustom status or error message beneath the display
titlestringHeader title on the ticket frame (default: "BOX OFFICE TURNSTILE")
terminalIdstringTerminal identifier code (default: "TERMINAL #07")
gatestringGate identifier (default: "GATE A-01")
clearMode"backspace" | "all"Whether CLR button acts as backspace or clears all digits (default: "backspace")
autoSubmitbooleanWhether to auto-submit when maxLength is reached (default: false)
classNamestringAdditional CSS class names