Skip to content

Phone Number Input

<pa-phone-number-input> | PaPhoneNumberInputGroup

A phone number input component with country selection dropdown and automatic number validation. Supports international phone number formatting with country flags and dialing codes.

vue
<template>
  <pa-phone-number-input v-model="phoneNumber" label="Phone Number" />
</template>

<script setup>
import { ref } from 'vue'

const phoneNumber = ref(null)
</script>

Examples

Basic Usage

Simple phone number input with country selection.

vue
<template>
  <pa-phone-number-input v-model="contactNumber" label="Contact Number" />
</template>

Required Field

Phone number input with validation requirement.

div.template-wrapper

vue
<template>
  <pa-phone-number-input 
    label="Required Phone" 
    required 
  />
</template>

<script setup>
import { ref } from 'vue'

const requiredPhone = ref(null)
</script>

Mobile Number Validation

Specifically validate mobile numbers only.

vue
<template>
  <pa-phone-number-input 
    label="Mobile Number" 
    :is-mobile="true"
  />
</template>

Custom Placeholder

Phone number input with custom placeholder text.

vue
<template>
  <pa-phone-number-input 
    label="Business Phone" 
    placeholder="Enter business number"
  />
</template>

Disabled State

Read-only phone number input.

vue
<template>
  <pa-phone-number-input 
    label="Support Line" 
    :disabled="true"
  />
</template>

Importing

typescript
import { PaPhoneNumberInputGroup } from '@payadvantage/ui-components'

Properties

NameDescriptionTypeDefault
modelValueThe phone number object with country and number (used with v-model).PhoneNumber | nullnull
labelLabel text for the input field.string'Phone number'
placeholderPlaceholder text for the number input field.string''
requiredMakes the phone number input required for validation.booleanfalse
disabledDisables the entire phone number input component.booleanfalse
isMobileValidates that the number is specifically a mobile number.booleanfalse
requireSmsSendingValidates that SMS can be sent to the selected country.booleanfalse
filterCountriesFunction to filter available countries in the dropdown.(countries: Country[]) => Country[]undefined
sfSelectorCustom selector for testing frameworks.string''

PhoneNumber Object Structure

typescript
interface PhoneNumber {
  countryId: string  // Country identifier (e.g., 'US', 'CA', 'GB')
  number: string     // Phone number digits only
}

Events

NameDescription
update:modelValueEmitted when the phone number changes (for v-model).
focusEmitted when the number input field receives focus.
blurEmitted when the number input field loses focus.

Dependencies

  • libphonenumber-js: International phone number parsing and validation
  • @vueform/multiselect: Country selection dropdown component
  • PaInput: Base input component for number entry
  • Bootstrap CSS: Form styling and layout

Design Notes

The phone number input component provides:

  • International support: Country selection with flags and dialing codes
  • Automatic validation: Real-time phone number format validation
  • Smart formatting: Automatically formats numbers based on country
  • SMS validation: Optional validation for SMS-capable numbers
  • Mobile detection: Can specifically validate mobile numbers

Visual Design

  • Country flag dropdown on the left with dialing code display
  • Standard input field for number entry with masking
  • Real-time validation feedback and warnings
  • Consistent styling with other form components

Interaction Patterns

  • Country selection updates dialing code and validation rules
  • Number formatting happens on blur/enter key
  • Visual feedback for invalid numbers or unsupported countries
  • Focus states show dialing code for better UX

This component is ideal for:

  • Registration forms: User sign-up with phone verification
  • Contact forms: Business contact information
  • Shipping forms: Delivery contact numbers
  • Emergency contacts: Critical contact information
  • International applications: Multi-country phone support

Accessibility Notes

  • Proper label association with form controls
  • Country dropdown is keyboard navigable
  • Validation messages are announced to screen readers
  • Disabled state is properly communicated
  • Required field indication for assistive technologies