Phone Input

An international phone number input with country selection and validation.

Overview

The PhoneInput component provides an international phone number input with country code selection. Built on react-phone-number-input, it includes a searchable country selector with flags and automatic phone number formatting.

Usage

import { PhoneInput } from "@tilt-legal/cubitt-components/primitives";
<PhoneInput placeholder="Enter phone number" />

The component automatically formats phone numbers according to the selected country's format. It uses the react-phone-number-input library which follows international phone number standards.


Examples

Basic

A standard phone input with country selection.

Sizes

Phone input in different sizes.


API Reference

PhoneInput

The root component for international phone number input with country selection.

PropTypeDefaultDescription
valuestringThe phone number value in E.164 format (controlled).
onChange(value: string | undefined) => voidCallback when the phone number changes.
variant"sm" | "md" | "lg""md"Size variant of the input.
placeholderstringPlaceholder text for the input.
disabledbooleanfalseWhether the input is disabled.
readOnlybooleanfalseWhether the input is read-only.
defaultCountryCountry"AU"Default country code (e.g., "US", "GB", "AU").
countriesCountry[]Array of country codes to display. Shows all if not specified.
popupClassNamestringAdditional CSS classes for the country selection popup.
classNamestringAdditional CSS classes for the input element.
aria-invalidbooleanIndicates validation state, applies error styling when true.

Types

import type { PhoneCountry } from "@tilt-legal/cubitt-components/primitives";

// PhoneCountry is an alias for the Country type from react-phone-number-input
// Examples: "US", "GB", "AU", "DE", "FR", "JP", etc.

Notes

  • The component uses react-phone-number-input for phone number validation and formatting
  • Country flags are displayed using SVG flag components from react-phone-number-input/flags
  • The phone number value follows the E.164 format (e.g., "+14155552671")
  • The country selector includes a searchable dropdown with all countries
  • Invalid inputs are visually indicated with error styling when aria-invalid is true

On this page