Componentticket-stub3.78 KB gzipZero dependencies
Keypad
Numeric PIN keypad with tactile mechanical keys, visual pulse, and masked PIN display.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add keypadOr install the full npm package:
npm install bigbulluiUsage
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 helperZero 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 />| Prop | Type | Description |
|---|---|---|
| maxLength | number | Maximum length of the PIN code (default: 4) |
| value | string | Controlled PIN value |
| defaultValue | string | Default initial PIN value for uncontrolled mode |
| onValueChange | (pin: string) => void | Callback fired whenever the entered PIN value changes |
| onSubmit | (pin: string) => void | Callback fired when ENTER is pressed or PIN reaches maxLength |
| onClear | () => void | Callback fired when CLEAR is pressed |
| masked | boolean | Whether the PIN digits are masked (default: true) |
| allowMaskToggle | boolean | Whether to show a toggle button to reveal/mask the PIN (default: true) |
| enableSound | boolean | Whether to synthesize tactile mechanical key click audio via Web Audio API (default: true) |
| disabled | boolean | Whether all keypad inputs are disabled |
| status | "idle" | "validating" | "success" | "error" | Turnstile security validation status |
| statusMessage | string | Custom status or error message beneath the display |
| title | string | Header title on the ticket frame (default: "BOX OFFICE TURNSTILE") |
| terminalId | string | Terminal identifier code (default: "TERMINAL #07") |
| gate | string | Gate identifier (default: "GATE A-01") |
| clearMode | "backspace" | "all" | Whether CLR button acts as backspace or clears all digits (default: "backspace") |
| autoSubmit | boolean | Whether to auto-submit when maxLength is reached (default: false) |
| className | string | Additional CSS class names |