suiss/uim · React Native Component

Keypad

A numeric keypad with round digit keys, a delete key and an optional decimal or biometric key.

Keypad is an open-source mobile component from suiss/uim for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Keypad on iOS in light mode

Keypad lays out digits 1 to 9 in three rows and a bottom row with an accessory key, 0 and a delete key. Each key is a KeypadKey, a round Pressable with the button role. Digit keys have a filled background; the accessory and delete keys use the plain variant with no fill.

Use it for PIN entry, amounts and other numeric input where the system keyboard is not wanted.

Installation

$ pnpm dlx @esuiss/uim@latest add keypad

The CLI also adds what it builds on: Icon, Text.

Manual

  1. Install the dependencies:
npx expo install cn phosphor-react-native react-native-svg
  1. Add the pieces it builds on: Icon, Text.

  2. Copy the source into components/ui/keypad.tsx:

uniwind/components/ui/keypad.tsx
import { cn } from "cn"
import {
  BackspaceIcon,
  FingerprintIcon,
  type Icon as PhosphorIcon,
} from "phosphor-react-native"
import type * as React from "react"
import { Pressable, View } from "react-native"
import { Icon, IconClassContext } from "@/components/ui/icon"
import { Text, TextClassContext } from "@/components/ui/text"

type KeypadDigit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"

type KeypadKeyValue = KeypadDigit | "decimal" | "delete" | "biometric"

type KeypadAccessoryKey = "decimal" | "biometric"
  1. Update the import paths to match your project.

Usage

import { KeypadKey, Keypad } from "@/components/ui/keypad"
<KeyLog />

Handle input in onKeyPress, which receives a digit string ("0" to "9"), "decimal", "delete" or "biometric". The keypad holds no value of its own.

Set accessoryKey to decimal or biometric to fill the bottom-left slot; otherwise it stays empty. Change the decimal character with decimalSeparator and the biometric icon with biometricIcon.

Use deleteDisabled to turn off only the delete key, for example when the value is empty. KeypadKey is exported for custom layouts, along with the KeypadDigit, KeypadKeyValue and KeypadAccessoryKey types.

Examples

Decimal

A keypad with a decimal separator key.

iOS
Keypad (decimal) on iOS in light mode

Biometric

A keypad with a biometric key.

iOS
Keypad (biometric) on iOS in light mode

Disabled

A fully disabled keypad.

iOS
Keypad (disabled) on iOS in light mode

API Reference

KeypadKey

A single round key that passes text and icon styles to its children.

ExtendsReact.ComponentProps<typeof Pressable>
PropType
About
default with a filled background, or plain without one.
Type
"default""plain"
Default
"default"
Type
string
Default
—
Type
React.ReactNode
Default
—

Keypad

The full grid of keys.

ExtendsReact.ComponentProps<typeof View>
PropType
About
Called with the pressed key value.
Type
(key: KeypadKeyValue) => void
Default
—
About
Bottom-left key: decimal or biometric.
Type
KeypadAccessoryKey
Default
—
About
Character shown on the decimal key. Defaults to ..
Type
string
Default
"."
About
Phosphor icon for the biometric key. Defaults to FingerprintIcon.
Type
PhosphorIcon
Default
FingerprintIcon
About
Accessibility label for the biometric key.
Type
string
Default
"Use biometrics"
About
Accessibility label for the decimal key.
Type
string
Default
"Decimal separator"
About
Accessibility label for the delete key.
Type
string
Default
"Delete"
About
Disables every key.
Type
boolean
Default
false
About
Disables only the delete key.
Type
boolean
Default
false
About
Extra classes applied to each key.
Type
string
Default
—

Accessibility

  • Every key has the button role and an accessibilityLabel: the digit itself, or decimalLabel, biometricLabel and deleteLabel for the other keys.
  • Disabled keys set disabled in their accessibility state and block presses.
  • Translate the default labels (Decimal separator, Use biometrics, Delete) for localized apps.

Notes

  • Filled keys use bg-control, bg-control-pressed when pressed and bg-control-disabled when disabled.
  • Digits use text-2xl with tabular numbers.
  • Light and dark colors follow the system appearance.