Phone Input
Use catnip-input-phone when a user enters a phone number that should be stored with an explicit country code. For arbitrary text, use Input. For numeric quantities, use Number Input. For choosing a country without entering a phone number, use Dropdown.
Behaviour
- State: Bind
model-value/.modelValueas{ countryCode, countryIsoCode, phoneNumber } | null.countryCodeis the dial prefix, whilecountryIsoCodekeeps countries with shared prefixes distinct. The localphoneNumberis stored as digits only; Catnip does not validate it by country. - Defaults: Use
default-country-codewhen the product context knows the expected country. Keep the defaultautofor account/profile forms where browser locale is a reasonable hint. - International entry: Users can type or paste
+47...,+44..., and similar values. The component selects the longest matching dial code and moves the remaining digits into the local number field. - Filtering: The country picker supports country names, ISO codes, and dial codes. The built-in search row is sticky inside the list; avoid adding a separate country search field around it.
Composition
- Labels:
labelprop orlabelslot;label.action/label.suffixmatch Input. - Supporting text: Pass
supporting-texton the host. Use it for format hints or validation messages such as “Include your mobile number.” - Clear button: Enable
show-clear-buttonwhen phone input is optional or frequently edited. Clearing removes the model value while keeping the current country selection visible.
Validation
V1 does not include libphonenumber or country-aware validation. Validate in the product layer when exact formatting or reachability matters, then set intent="danger" and supporting-text for errors.
Best practices
- Prefer a visible label such as Phone number over relying on placeholder copy.
- Do not store only the dial code; keep
countryIsoCodewithcountryCodeso countries sharing a dial code remain distinguishable. - Do not use the phone field for one-time passcodes, PINs, or numeric IDs; those are text inputs with different semantics.