PhoneField component allows users to enter phone numbers with automatic country code selection and formatting.
Prop | Type | Default |
|---|---|---|
No dataThere are no records to display | ||
The component binds three values: the phone number, country code, and dial code:
<script>
let value = $state(''); // Phone number: "5551234567"
let countryCode = $state(''); // ISO code: "us"
let dialCode = $state(''); // Dial code: "1"
</script>
<PhoneField
name="phone"
bind:value
bind:countryCode
bind:dialCode
/> You can pin specific countries to the top of the list for easier access:
<PhoneField
name="phone"
priorityCountries={['us', 'gb', 'ca', 'au']}
bind:value
bind:countryCode
bind:dialCode
/> The component creates two form inputs:
name - Contains the phone number valuedialCodeName - Contains the dial code (default: "dialCode")