Documentation Index
Fetch the complete documentation index at: https://mintlify.com/rijvi-mahmud/shaddy/llms.txt
Use this file to discover all available pages before exploring further.
PhoneInput provides a polished, internationally-aware phone number field for React applications. It combines a searchable country dropdown — complete with circular flag icons — with a standard text input that automatically formats and validates numbers as the user types. Country detection is bi-directional: selecting a country from the dropdown prefixes the calling code into the input, and typing a valid international number into the input automatically updates the selected country flag. The country selector can be hidden entirely for simpler form designs.
Installation
Install manually — dependencies
If you prefer to install by hand, start with the required npm packages:
Usage
With country selector (default)
With a pre-selected default country
Without the country selector
SetwithCountryCodeSelector={false} to render a plain phone input with a globe icon — useful when country selection is handled elsewhere or not required:
Props
Callback invoked whenever the phone number value changes. Receives the current input string, normalised with a leading
+ where possible.Callback invoked when the selected country changes — either through the dropdown or by parsing a typed international number. Receives the full
CountryData object from country-data-list, or undefined when no country can be determined.Sets the initially selected country using a human-readable enum key (e.g.
"United_States", "United_Kingdom", "Germany"). The component looks up the corresponding alpha-2 code and pre-populates both the flag and the calling-code prefix.When
true (default), renders the country dropdown to the left of the phone input. When false, renders only the text input with a globe icon for undetected countries and a flag icon once a country is identified from the typed number.Controlled value for the phone input field. When provided, the component reflects this value instead of its internal state.
Placeholder text displayed inside the phone number input when it is empty.
When
true, adjusts the input styling to render inline — removing the left rounded corners so the input joins seamlessly with an adjacent element such as a form grid column.Disables both the country dropdown and the phone input when
true.Additional CSS class names applied to the outer wrapper element.
PhoneInput extends React.InputHTMLAttributes<HTMLInputElement> (excluding onChange), so standard props like name, id, aria-label, and autoComplete are all forwarded to the underlying <input> element.CountryData type
The CountryData type is the raw country record from the country-data-list package. Key fields you are likely to use in onCountryChange:
CountryAlpha2 enum
The CountryAlpha2 enum is exported from the component and maps human-readable country name keys to their ISO alpha-2 codes. Use its keys for the defaultCountry prop: