BDMG UI

Phone Number Input

US-format phone input: displays as (123) 456 - 7890. Stores and passes only digits (max 10). Handles backspace and restricts to numbers.

Installation

tsx
import { PhoneNumberInput } from "@workspace/ui/components/phone-number-input"

Basic usage

tsx
const [digits, setDigits] = useState("")

<PhoneNumberInput
  label="Phone"
  value={digits}
  onChange={setDigits}
/>

Props

PropTypeDefaultDescription
labelstring-Label above the input.
errorstring-Error message shown below.
hintstring-Hint text below.
valuestring-Digits only (e.g. 10 digits for US).
onChange(digits: string) => void-Called with digits only when value changes.
containerClassNamestring-Classes for the wrapper.
inputClassNamestring-Classes for the input element.