Import
Usage
Props
Callback fired on input change or country change with validation status.
country: Country prefix (e.g.,"+34")value: Phone number without prefixisValid: Whether phone is valid for selected country region
ISO country code (e.g.,
"ES", "US", "FR") to pre-select. Must match a countryCode in countryOptions.Array of country options with prefix and countryCode. Shows country selector on left side when provided.
Inherits all standard Input component props (placeholder, disabled, design, error, etc.) via
InputProps.CountryProps Interface
Validation
Uses google-libphonenumber library to validate phone numbers:- Region-specific: Validates format for the selected country
- Length check: Only validates if phone length is between 6-18 characters (with prefix)
- Real-time: Validation runs on every input change
- Format tolerant: Automatically strips whitespace before validation
Examples
Basic Usage with Spanish Phone
Multiple Countries
Form Integration with Error Handling
With Default Value
Without Country Selector
Country Selector Behavior
- LeftContent: Country selector appears as
LeftContentprop of Input component - Focus styling: Only shows selector focus when input has
design="secondary"and is focused or has value - Flag icons: Typically includes flag emoji or icon (handled by SelectPhone component)
- Searchable: SelectPhone component allows searching countries
SelectPhone Component
The country selector is a separate component (SelectPhone) that:
- Displays current country with flag and prefix
- Opens dropdown to search and select countries
- Handles focus states
- Accepts
CountryProps[]as options
Input Formats Accepted
The component handles various input formats:Validation Examples
Spanish Mobile (ES: +34)
US Phone (US: +1)
UK Phone (GB: +44)
Dependencies
- google-libphonenumber: Phone validation library
- Uses
PhoneNumberUtil.getInstance()for validation isValidNumberForRegion()checks format for specific country
Troubleshooting
Phone shows as invalid but looks correct
- Check the country code matches the phone number format
- Some countries have multiple valid formats
- Ensure phone number length is within 6-18 characters (including prefix)
Country selector not appearing
- Verify
countryOptionsprop is provided - Check that CountryProps objects have all required fields
Default country not selected
- Ensure
countryprop matches acountryCodeincountryOptions - Country codes are case-sensitive (“ES” not “es”)