"use client";
import { KeypadGrid } from "@pixxl-tools/components";| Prop | Type | Default | Description |
|---|---|---|---|
keys (required) | readonly KeypadKey[] | — | value, label, description, ariaLabel, variant, span, rowSpan, disabled, shortcuts, autoFocus. |
columns | number | 3 | Grid columns (default 3); keys can span several. |
doubleTapGuard | KeypadDoubleTapGuard | — | Refuse a second pointer tap that follows an accepted one too quickly (and, with radius, too close) — an accidental double tap. Keyboard presses are never refused. Default off. |
onPress | (value: string, details: KeypadPressDetails) => void | — | Taps, keyboard activation and shortcuts. |
onPressRejected | (value: string, key: KeypadKey) => void | — | A tap was refused by doubleTapGuard (play a "deny" cue here). |
disabled | boolean | — | Disables interaction. |
keyboard | boolean | "global" | true | Physical keyboard shortcuts: true (default) while focus is inside the pad; "global" also while focus is elsewhere on the page — on the body, or on a button, radio, checkbox, link or slider outside the pad (it keeps Space, Escape, Tab and the arrow/Home/End/Page keys; buttons and links also keep Enter, radios, checkboxes, switches and sliders do not) — but never while a text field, select, editable content, combobox, spin button, listbox, menu, tree, grid or another pad has focus, inside a dialog the pad is not in, or during IME composition; false off. After digits were typed (shortcuts) and before focus moves again, Enter submits them (presses the enter key) wherever focus is, also on a focused key of the pad, instead of activating the focused control. |
label | string | from messages | Accessible name of the pad (default from messages). |
longPressMs | number | 500 | Long press (suppresses the tap). |
onLongPress | (value: string, key: KeypadKey) => void | 500 | Held for longPressMs: fires instead of onPress. |
size | "sm" | "md" | "lg" | md | Minimum key height (default md): sm 44 px (--pixxl-size-touch-target, for small phones and landscape), md 56 px, lg 64 px. Tune it with the --pixxl-keypad-key-min custom property on the pad (never below 44 px); give the pad a height and the rows grow to fill it. |
vibrate | number | — | navigator.vibrate duration on accepted presses, where supported (ms). |
keysrequiredreadonly KeypadKey[]
value, label, description, ariaLabel, variant, span, rowSpan, disabled, shortcuts, autoFocus.
columnsdefault 3number
Grid columns (default 3); keys can span several.
doubleTapGuardKeypadDoubleTapGuard
Refuse a second pointer tap that follows an accepted one too quickly (and, with radius, too close) — an accidental double tap. Keyboard presses are never refused. Default off.
onPress(value: string, details: KeypadPressDetails) => void
Taps, keyboard activation and shortcuts.
onPressRejected(value: string, key: KeypadKey) => void
A tap was refused by doubleTapGuard (play a "deny" cue here).
disabledboolean
Disables interaction.
keyboarddefault trueboolean | "global"
Physical keyboard shortcuts: true (default) while focus is inside the pad; "global" also while focus is elsewhere on the page — on the body, or on a button, radio, checkbox, link or slider outside the pad (it keeps Space, Escape, Tab and the arrow/Home/End/Page keys; buttons and links also keep Enter, radios, checkboxes, switches and sliders do not) — but never while a text field, select, editable content, combobox, spin button, listbox, menu, tree, grid or another pad has focus, inside a dialog the pad is not in, or during IME composition; false off. After digits were typed (shortcuts) and before focus moves again, Enter submits them (presses the enter key) wherever focus is, also on a focused key of the pad, instead of activating the focused control.
labeldefault from messagesstring
Accessible name of the pad (default from messages).
longPressMsdefault 500number
Long press (suppresses the tap).
onLongPressdefault 500(value: string, key: KeypadKey) => void
Held for longPressMs: fires instead of onPress.
sizedefault md"sm" | "md" | "lg"
Minimum key height (default md): sm 44 px (--pixxl-size-touch-target, for small phones and landscape), md 56 px, lg 64 px. Tune it with the --pixxl-keypad-key-min custom property on the pad (never below 44 px); give the pad a height and the rows grow to fill it.
vibratenumber
navigator.vibrate duration on accepted presses, where supported (ms).
Other props are passed to the root element (HTMLAttributes<HTMLDivElement>), including className, style, id and aria-* attributes.
Darts: — 0 refused
const keys = [1, 2, 3, 4, 5].map((digit) => ({ id: String(digit), label: digit, value: String(digit) }));
const enter = (value: string) => console.log(value);
const cue = (sound: "deny") => console.log(sound);
<KeypadGrid columns={5} keys={keys} onPress={enter} doubleTapGuard={{ ms: 180, radius: 28 }} onPressRejected={() => cue("deny")} />