# Angular PhoneInput Component

PhoneInput enters an international phone number: a searchable list of countries with their flag and dial code, and a number input formatted as you type. The value is an E.164 string, the country follows the dial code of a typed or pasted number, and the built-in metadata checks the number without any dependency, with libphonenumber-js as an optional full validator.

## Basic

PhoneInput is bound with ngModel . Pick a country in the searchable list, by its name or its dial code, and type the number: it is formatted as you type, without moving the caret, and the value is the number in E.164 format, ready to store or to send to an SMS API. Typing or pasting a number that starts with + or 00 selects the country of its dial code.

```typescript
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { PhoneInputModule } from '@exhaustive-ui/core/phoneinput';

@Component({
    template: `
        <div class="card flex flex-col items-center gap-3">
            <p-phone-input [(ngModel)]="phone" defaultCountry="FR" ariaLabel="Phone number" />
            <span class="text-sm font-mono">Value: {{ phone || 'null' }}</span>
        </div>
    `,
    standalone: true,
    imports: [FormsModule, PhoneInputModule]
})
export class PhoneinputBasicDemo {
    phone: string | null = null;
}
```

## Default and Preferred Countries

defaultCountry is selected while country is not set; [(country)] is two-way and follows the dial code of the number typed, pasted or written. preferredCountries are listed first, in their order, above a separator, and onlyCountries or excludeCountries limit the list. The names come from Intl.DisplayNames in the locale of the component, the lang of the document by default, with English as the fallback; the flags are emoji, so no image is loaded.

```typescript
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { PhoneInputModule } from '@exhaustive-ui/core/phoneinput';

@Component({
    template: `
        <div class="card flex flex-col items-center gap-4">
            <div class="flex flex-col items-center gap-2">
                <label for="phone-preferred" class="font-medium">Preferred countries</label>
                <p-phone-input [(ngModel)]="phone1" [(country)]="country" defaultCountry="US" [preferredCountries]="['US', 'CA', 'GB']" inputId="phone-preferred" />
                <span class="text-sm font-mono">Country: {{ country }}</span>
            </div>
            <div class="flex flex-col items-center gap-2">
                <label for="phone-only" class="font-medium">Benelux only, in French</label>
                <p-phone-input [(ngModel)]="phone2" defaultCountry="BE" [onlyCountries]="['BE', 'NL', 'LU']" locale="fr" inputId="phone-only" />
            </div>
        </div>
    `,
    standalone: true,
    imports: [FormsModule, PhoneInputModule]
})
export class PhoneinputCountriesDemo {
    phone1: string | null = null;

    phone2: string | null = null;

    country: string | undefined = undefined;
}
```

## Value Format

valueFormat sets the format of the value: e164 (the default, +33612345678 ), international ( +33 6 12 34 56 78 ) or national ( 06 12 34 56 78 ). The component reads any of them back; a national value is read in the selected country. The same helpers are exported for your own code: phoneInputFormat , phoneInputParse and phoneInputValidate .

```typescript
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { PhoneInputModule } from '@exhaustive-ui/core/phoneinput';

@Component({
    template: `
        <div class="card flex flex-col items-center gap-4">
            @for (format of formats; track format) {
                <div class="flex flex-col items-center gap-2">
                    <label [for]="'phone-' + format" class="font-medium">{{ format }}</label>
                    <p-phone-input [(ngModel)]="values[format]" [valueFormat]="format" defaultCountry="FR" [inputId]="'phone-' + format" />
                    <span class="text-sm font-mono">Value: {{ values[format] || 'null' }}</span>
                </div>
            }
        </div>
    `,
    standalone: true,
    imports: [FormsModule, PhoneInputModule]
})
export class PhoneinputValueformatDemo {
    formats = ['e164', 'international', 'national'] as const;

    values: Record<string, string | null> = { e164: '+33612345678', international: '+33612345678', national: '+33612345678' };
}
```

## Validation

The built-in validation is light : it checks the dial code, the length of the national number for its country and, for about fifty countries, its leading digits. It needs no dependency and works during server-side rendering, but it cannot tell whether a number is allocated, nor whether it is a mobile. valid() and validation() give the result, and the component adds a phoneNumber error, with its reason , to its form control; an empty value is left to required . Set validateNumber to false to keep the field valid whatever the number. For a full validation, install libphonenumber-js (MIT), an optional peer dependency, and pass a validator . It is loaded with a dynamic import, in the browser only, when the component is displayed; the built-in check is used until then. The max metadata also knows the type of the numbers, so types can accept mobiles only, for SMS.

```typescript
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { libphonenumberValidator, PhoneInputModule } from '@exhaustive-ui/core/phoneinput';
import { MessageModule } from '@exhaustive-ui/core/message';

@Component({
    template: `
        <div class="card flex flex-col items-center gap-6">
            <div class="flex flex-col gap-2">
                <label for="phone-light" class="font-medium">Built-in validation</label>
                <p-phone-input #light [(ngModel)]="phone1" defaultCountry="FR" inputId="phone-light" ariaDescribedBy="phone-light-state" />
                <p-message id="phone-light-state" [severity]="phone1 ? (light.valid() ? 'success' : 'error') : 'secondary'" size="small" variant="simple">{{
                    phone1 ? (light.valid() ? 'Valid length' : 'Not valid: ' + light.validation().reason) : 'Type a number'
                }}</p-message>
            </div>
            <div class="flex flex-col gap-2">
                <label for="phone-full" class="font-medium">Mobile numbers, with libphonenumber-js</label>
                <p-phone-input #full [(ngModel)]="phone2" defaultCountry="FR" [validator]="mobileValidator" inputId="phone-full" ariaDescribedBy="phone-full-state" />
                <p-message id="phone-full-state" [severity]="phone2 ? (full.valid() ? 'success' : 'error') : 'secondary'" size="small" variant="simple">{{
                    phone2 ? (full.valid() ? 'Valid ' + full.validation().type : 'Not a valid mobile number') : 'Try 06 12 34 56 78 and 01 23 45 67 89'
                }}</p-message>
            </div>
        </div>
    `,
    standalone: true,
    imports: [FormsModule, PhoneInputModule, MessageModule]
})
export class PhoneinputValidationDemo {
    phone1: string | null = '+3361234';

    phone2: string | null = null;

    // libphonenumber-js is loaded in the browser, the first time a PhoneInput with this validator is displayed
    mobileValidator = libphonenumberValidator(() => import('libphonenumber-js/max'), { types: ['MOBILE', 'FIXED_LINE_OR_MOBILE'] });
}
```

## Template

The country template replaces the content of a country in the list, and selectedcountry the content of the selected country. Their context gives the country ( code , localized name , dialCode , flag and preferred ) and whether it is selected . Keep the text of the selected country in the accessible name of the Select, which is the country label followed by the name and the dial code: show the name or the dial code, not another text.

```typescript
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { PhoneInputModule } from '@exhaustive-ui/core/phoneinput';

@Component({
    template: `
        <div class="card flex justify-center">
            <p-phone-input [(ngModel)]="value" defaultCountry="JP" [preferredCountries]="['JP', 'KR', 'CN']" ariaLabel="Phone number">
                <ng-template #selectedcountry let-country>
                    <span class="inline-flex items-center gap-2">
                        <span>{{ country.name }}</span>
                        <span class="font-semibold" dir="ltr">{{ country.dialCode }}</span>
                    </span>
                </ng-template>
                <ng-template #country let-country let-selected="selected">
                    <span class="flex items-center gap-3 w-full">
                        <span class="text-xl" aria-hidden="true">{{ country.flag }}</span>
                        <span class="flex flex-col">
                            <span [class.font-semibold]="selected">{{ country.name }}</span>
                            <span class="text-sm" dir="ltr">{{ country.code }} · {{ country.dialCode }}</span>
                        </span>
                    </span>
                </ng-template>
            </p-phone-input>
        </div>
    `,
    standalone: true,
    imports: [FormsModule, PhoneInputModule]
})
export class PhoneinputTemplateDemo {
    value: string | null = null;
}
```

## Float Label

A floating label appears on top of the field. Since the country and its dial code are always shown, the label stays floated. Point the label at inputId . Visit FloatLabel documentation for more information.

```typescript
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { PhoneInputModule } from '@exhaustive-ui/core/phoneinput';
import { FloatLabelModule } from '@exhaustive-ui/core/floatlabel';

@Component({
    template: `
        <div class="card flex flex-wrap justify-center items-end gap-4">
            <p-float-label>
                <p-phone-input [(ngModel)]="value1" defaultCountry="US" inputId="phone_over_label" />
                <label for="phone_over_label">Over Label</label>
            </p-float-label>
            <p-float-label variant="in">
                <p-phone-input [(ngModel)]="value2" defaultCountry="US" inputId="phone_in_label" />
                <label for="phone_in_label">In Label</label>
            </p-float-label>
            <p-float-label variant="on">
                <p-phone-input [(ngModel)]="value3" defaultCountry="US" inputId="phone_on_label" />
                <label for="phone_on_label">On Label</label>
            </p-float-label>
        </div>
    `,
    standalone: true,
    imports: [FormsModule, PhoneInputModule, FloatLabelModule, RouterModule]
})
export class PhoneinputFloatlabelDemo {
    value1: string | null = null;

    value2: string | null = null;

    value3: string | null = null;
}
```

## Ifta Label

IftaLabel is used to create infield top aligned labels. Visit IftaLabel documentation for more information.

```typescript
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { PhoneInputModule } from '@exhaustive-ui/core/phoneinput';
import { IftaLabelModule } from '@exhaustive-ui/core/iftalabel';

@Component({
    template: `
        <div class="card flex justify-center">
            <p-ifta-label>
                <p-phone-input [(ngModel)]="value" defaultCountry="DE" inputId="phone_ifta" />
                <label for="phone_ifta">Mobile</label>
            </p-ifta-label>
        </div>
    `,
    standalone: true,
    imports: [FormsModule, PhoneInputModule, IftaLabelModule, RouterModule]
})
export class PhoneinputIftalabelDemo {
    value: string | null = '+4915123456789';
}
```

## Sizes

PhoneInput provides small and large sizes as alternatives to the base, applied to the country Select and to the number input.

```typescript
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { PhoneInputModule } from '@exhaustive-ui/core/phoneinput';

@Component({
    template: `
        <div class="card flex flex-col items-center gap-4">
            <p-phone-input [(ngModel)]="value1" size="small" defaultCountry="GB" ariaLabel="Small" placeholder="Small" />
            <p-phone-input [(ngModel)]="value2" defaultCountry="GB" ariaLabel="Normal" placeholder="Normal" />
            <p-phone-input [(ngModel)]="value3" size="large" defaultCountry="GB" ariaLabel="Large" placeholder="Large" />
        </div>
    `,
    standalone: true,
    imports: [FormsModule, PhoneInputModule]
})
export class PhoneinputSizesDemo {
    value1: string | null = null;

    value2: string | null = null;

    value3: string | null = null;
}
```

## Filled

Specify the variant property as filled to display the component with a higher visual emphasis than the default outlined style.

```typescript
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { PhoneInputModule } from '@exhaustive-ui/core/phoneinput';

@Component({
    template: `
        <div class="card flex justify-center">
            <p-phone-input [(ngModel)]="value" variant="filled" defaultCountry="ES" ariaLabel="Phone number" />
        </div>
    `,
    standalone: true,
    imports: [FormsModule, PhoneInputModule]
})
export class PhoneinputFilledDemo {
    value: string | null = null;
}
```

## Fluid

The fluid prop makes the component take up the full width of its container when set to true; the number input takes the space left by the country Select.

```typescript
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { PhoneInputModule } from '@exhaustive-ui/core/phoneinput';

@Component({
    template: `
        <div class="card">
            <p-phone-input [(ngModel)]="value" fluid defaultCountry="IT" ariaLabel="Phone number" />
        </div>
    `,
    standalone: true,
    imports: [FormsModule, PhoneInputModule]
})
export class PhoneinputFluidDemo {
    value: string | null = null;
}
```

## Disabled

When disabled is present, the country and the number cannot be changed nor focused. With readonly , they can be focused and read, but not changed.

```typescript
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { PhoneInputModule } from '@exhaustive-ui/core/phoneinput';

@Component({
    template: `
        <div class="card flex flex-wrap justify-center gap-4">
            <p-phone-input [(ngModel)]="value" disabled ariaLabel="Disabled phone number" />
            <p-phone-input [(ngModel)]="value" readonly ariaLabel="Read-only phone number" />
        </div>
    `,
    standalone: true,
    imports: [FormsModule, PhoneInputModule]
})
export class PhoneinputDisabledDemo {
    value: string | null = '+12015550123';
}
```

## Invalid

The invalid state is applied using the invalid property to indicate failed validation, here while the number is not valid.

```typescript
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { PhoneInputModule } from '@exhaustive-ui/core/phoneinput';

@Component({
    template: `
        <div class="card flex flex-wrap justify-center gap-4">
            <p-phone-input #first [(ngModel)]="value1" [invalid]="!first.valid()" defaultCountry="FR" ariaLabel="Phone number" />
            <p-phone-input #second [(ngModel)]="value2" [invalid]="!second.valid()" variant="filled" defaultCountry="FR" ariaLabel="Phone number, filled" />
        </div>
    `,
    standalone: true,
    imports: [FormsModule, PhoneInputModule]
})
export class PhoneinputInvalidDemo {
    value1: string | null = null;

    value2: string | null = null;
}
```

## Forms: Template Driven

The value is null while the field is empty, so required works as on the other fields, and the component adds a phoneNumber error when the number is not valid. Link the message with ariaDescribedBy so that it is read with the field.

```typescript
import { Component, inject } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MessageService } from '@exhaustive-ui/core/api';
import { PhoneInputModule } from '@exhaustive-ui/core/phoneinput';
import { ToastModule } from '@exhaustive-ui/core/toast';
import { MessageModule } from '@exhaustive-ui/core/message';
import { ButtonModule } from '@exhaustive-ui/core/button';

@Component({
    template: `
        <p-toast />
        <div class="card flex justify-center">
            <form #exampleForm="ngForm" (ngSubmit)="onSubmit(exampleForm)" class="flex flex-col gap-4 w-full md:w-[30rem]">
                <div class="flex flex-col gap-2">
                    <label for="phone-td" class="font-medium">Phone</label>
                    <p-phone-input #model="ngModel" [(ngModel)]="phone" name="phone" defaultCountry="FR" inputId="phone-td" ariaDescribedBy="phone-td-error" fluid [invalid]="model.invalid && (model.touched || exampleForm.submitted)" required />
                    @if (model.invalid && (model.touched || exampleForm.submitted)) {
                        <p-message id="phone-td-error" severity="error" size="small" variant="simple">{{ model.hasError('required') ? 'Phone is required.' : 'The phone number is not valid.' }}</p-message>
                    }
                </div>
                <button pButton severity="secondary" type="submit" class="self-start"><span pButtonLabel>Submit</span></button>
            </form>
        </div>
    `,
    standalone: true,
    imports: [FormsModule, PhoneInputModule, ToastModule, MessageModule, ButtonModule],
    providers: [MessageService]
})
export class PhoneinputTemplatedrivenformsDemo {
    messageService = inject(MessageService);

    phone: string | null = null;

    onSubmit(form: any) {
        if (form.valid) {
            this.messageService.add({ severity: 'success', summary: 'Success', detail: 'Form Submitted', life: 3000 });
            form.resetForm();
        }
    }
}
```

## Reactive Forms

PhoneInput can also be used with reactive forms, through the formControlName property. The phoneNumber error is added by the component itself; for a control that is not bound to a PhoneInput, such as a value imported from a file, use the phoneNumberValidator() function.

```typescript
import { Component, inject } from '@angular/core';
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { MessageService } from '@exhaustive-ui/core/api';
import { PhoneInputModule } from '@exhaustive-ui/core/phoneinput';
import { ToastModule } from '@exhaustive-ui/core/toast';
import { MessageModule } from '@exhaustive-ui/core/message';
import { ButtonModule } from '@exhaustive-ui/core/button';

@Component({
    template: `
        <p-toast />
        <div class="card flex justify-center">
            <form [formGroup]="exampleForm" (ngSubmit)="onSubmit()" class="flex flex-col gap-4 w-full md:w-[30rem]">
                <div class="flex flex-col gap-2">
                    <label for="phone-rf" class="font-medium">Phone</label>
                    <p-phone-input formControlName="phone" defaultCountry="US" [preferredCountries]="['US', 'CA']" inputId="phone-rf" ariaDescribedBy="phone-rf-error" fluid [invalid]="isInvalid('phone')" />
                    @if (isInvalid('phone')) {
                        <p-message id="phone-rf-error" severity="error" size="small" variant="simple">{{ exampleForm.get('phone')?.hasError('required') ? 'Phone is required.' : 'The phone number is not valid.' }}</p-message>
                    }
                </div>
                <button pButton severity="secondary" type="submit" class="self-start"><span pButtonLabel>Submit</span></button>
            </form>
        </div>
    `,
    standalone: true,
    imports: [ReactiveFormsModule, PhoneInputModule, ToastModule, MessageModule, ButtonModule],
    providers: [MessageService]
})
export class PhoneinputReactiveformsDemo {
    private fb = inject(FormBuilder);

    messageService = inject(MessageService);

    exampleForm: FormGroup;

    formSubmitted: boolean = false;

    constructor() {
        this.exampleForm = this.fb.group({
            phone: [null, Validators.required]
        });
    }

    onSubmit() {
        this.formSubmitted = true;
        if (this.exampleForm.valid) {
            this.messageService.add({ severity: 'success', summary: 'Success', detail: 'Form is submitted', life: 3000 });
            this.exampleForm.reset();
            this.formSubmitted = false;
        }
    }

    isInvalid(controlName: string) {
        const control = this.exampleForm.get(controlName);
        return control?.invalid && (control.touched || this.formSubmitted);
    }
}
```

## Signal Forms

PhoneInput can also be used with Angular Signal Forms . The [formField] directive binds the component to a string field, and the number check of the component shows up in the errors of the field with the phoneNumber kind. The field also sets the invalid and touched states of the component, so it is styled as invalid once the field is touched or the form is submitted. To check a phone number in a schema, outside the component, use phoneInputValidate(value).valid in a validate rule.

```typescript
import { Component, inject, signal } from '@angular/core';
import { form, FormField, required, submit } from '@angular/forms/signals';
import { MessageService } from '@exhaustive-ui/core/api';
import { PhoneInputModule } from '@exhaustive-ui/core/phoneinput';
import { ButtonModule } from '@exhaustive-ui/core/button';
import { ToastModule } from '@exhaustive-ui/core/toast';
import { MessageModule } from '@exhaustive-ui/core/message';

@Component({
    template: `
        <p-toast />
        <div class="card flex justify-center">
            <form novalidate (submit)="onSubmit($event)" class="flex flex-col gap-4 w-full md:w-[30rem]">
                <div class="flex flex-col gap-2">
                    <label for="phone-sf" class="font-medium">Phone</label>
                    <p-phone-input [formField]="contactForm.phone" defaultCountry="GB" inputId="phone-sf" ariaDescribedBy="phone-sf-error" fluid />
                    @let phone = contactForm.phone();
                    @if (phone.invalid() && phone.touched()) {
                        <p-message id="phone-sf-error" severity="error" size="small" variant="simple">{{ phone.errors()[0]?.kind === 'required' ? 'Phone is required.' : 'The phone number is not valid.' }}</p-message>
                    }
                </div>
                <button pButton severity="secondary" type="submit" class="self-start"><span pButtonLabel>Submit</span></button>
            </form>
        </div>
    `,
    standalone: true,
    imports: [FormField, PhoneInputModule, ButtonModule, ToastModule, MessageModule],
    providers: [MessageService]
})
export class PhoneinputSignalformsDemo {
    messageService = inject(MessageService);

    model = signal<{ phone: string }>({ phone: '' });

    contactForm = form(this.model, (f) => {
        required(f.phone);
    });

    onSubmit(event: Event) {
        event.preventDefault();
        submit(this.contactForm, async () => {
            this.messageService.add({ severity: 'success', summary: 'Success', detail: 'Form is submitted', life: 3000 });
            this.contactForm().reset({ phone: '' });
        });
    }
}
```

## Accessibility

Screen Reader The country is a Select : an element with the combobox role and a listbox popup with a search field. Its accessible name is the countryLabel followed by the selected country and its dial code, such as Country: France +33 , so it contains the dial code shown; the flags are hidden from screen readers and each option is read as its name and dial code. The number is an input of type tel with inputmode="tel" , which opens the phone keypad on mobile devices, and autocomplete="tel" , so that the browser can fill in a saved number, whose dial code then selects the country. Label it with a label element pointing at inputId , with ariaLabelledBy or with ariaLabel ; without any of them it is named by the numberLabel text. Link an error message with ariaDescribedBy ; aria-invalid follows the invalid state. The number is always written left to right, also in a right-to-left page. A polite live region announces the country selected when it is detected from a number typed or pasted, and that the number is not valid when the focus leaves an invalid number. All these texts can be replaced, or translated, with the labels input; an empty invalidMessage turns the announcement off, for example when your error message already has the alert role.

## Phone Input

PhoneInput enters an international phone number: a searchable list of countries with their flag and dial code, and a number input formatted as you type. The value is an E.164 string by default, and the built-in metadata checks the length and the leading digits of the number.

### Props

| Name | Type | Default | Description |
|------|------|---------|-------------|
| dt | Object | undefined | Defines scoped design tokens of the component. |
| unstyled | boolean | undefined | Indicates whether the component should be rendered without styles. |
| pt | PhoneInputPassThrough | undefined | Used to pass attributes to DOM elements inside the component. |
| ptOptions | PassThroughOptions | undefined | Used to configure passthrough(pt) options of the component. |
| required | boolean | false | There must be a value (if set). |
| invalid | boolean | false | When present, it specifies that the component should have invalid state style. |
| touched | boolean | undefined | Whether the field has been touched. Signal Forms sets it through  `[formField]` : the invalid style and  `aria-invalid`  then wait until the field is touched, or the form is submitted, like the error messages. Left unset,  `invalid`  applies at once. |
| $invalid | Signal<boolean> | - | The invalid state shown by the component:  `invalid` , once the field is touched when  `touched`  is set; undefined when  `invalid`  is unset. |
| disabled | boolean | false | When present, it specifies that the component should have disabled state style. |
| name | string | undefined | When present, it specifies that the name of the input. |
| fluid | boolean | false | Spans 100% width of the container when enabled. |
| variant | "filled" \| "outlined" | 'outlined' | Specifies the input variant of the component. |
| size | "small" \| "large" | undefined | Specifies the size of the component. |
| inputSize | number | undefined | Specifies the visible width of the input element in characters. |
| pattern | string | undefined | Specifies the value must match the pattern. |
| min | number | undefined | The value must be greater than or equal to the value. |
| max | number | undefined | The value must be less than or equal to the value. |
| step | number | undefined | Unless the step is set to the any literal, the value must be min + an integral multiple of the step. |
| minlength | number | undefined | The number of characters (code points) must not be less than the value of the attribute, if non-empty. |
| maxlength | number | undefined | The number of characters (code points) must not exceed the value of the attribute. |
| country | string | - | ISO 3166-1 alpha-2 code of the selected country, such as  `FR` . Two-way bindable; it also changes when the number typed, pasted or written starts with another dial code. |
| defaultCountry | string | - | Country selected while the country input is not set, such as  `US` . |
| preferredCountries | string[] | - | ISO codes of the countries listed first, in this order. |
| onlyCountries | string[] | - | ISO codes of the only countries to list. |
| excludeCountries | string[] | - | ISO codes of the countries not to list. |
| valueFormat | PhoneInputValueFormat | 'e164' | Format of the value:  `e164`  (+33612345678),  `international`  (+33 6 12 34 56 78) or  `national`  (06 12 34 56 78). |
| locale | string | - | Locale of the names of the countries, given by Intl.DisplayNames. Defaults to the lang attribute of the document, then English. |
| filter | boolean | true | Whether the list of countries has a search field. |
| validator | PhoneInputValidator | - | A validation strategy that replaces the built-in length and prefix check once it is loaded, such as  `libphonenumberValidator(() => import('libphonenumber-js/max'))` . |
| validateNumber | boolean | true | Whether the component adds a  `phoneNumber`  error to its form control when the number is not valid. An empty value is left to  `required` . |
| placeholder | string | - | Placeholder of the number input. |
| autocomplete | string | 'tel' | Autocomplete attribute of the number input. |
| readonly | boolean | false | When present, the number and the country can be read but not changed. |
| inputId | string | - | Identifier of the number input, for a label element. |
| tabindex | number | - | Index of the number input in the tab order. |
| ariaLabel | string | - | Accessible name of the number input. |
| ariaLabelledBy | string | - | Identifier of the element that labels the number input. |
| ariaDescribedBy | string | - | Identifiers of the elements that describe the number input, such as an error message. |
| appendTo | any | - | Target element to attach the list of countries to,  `'body'`  or  `'self'` . |
| scrollHeight | string | '16rem' | Height of the list of countries before it scrolls. |
| labels | Partial<PhoneInputLabels> | - | Texts of the component, merged with the English defaults. |
| countries | Signal<PhoneInputCountry[]> | - | The countries of the list, the preferred ones first, then by name in the locale. |
| selectedCountry | Signal<PhoneInputCountry> | - | The selected country, with its localized name. |
| number | Signal<PhoneInputNumber> | - | The number typed, parsed; null while the input is empty. |
| validation | Signal<PhoneInputValidationResult> | - | Result of the validation of the number: the validator once loaded, the built-in length and prefix check otherwise. |
| valid | Signal<boolean> | computed(() => this.validation().valid) | Whether the number is valid. |

### Emits

| Name | Parameters | Description |
|------|------------|-------------|
| onCountryChange | event: PhoneInputCountryChangeEvent | Callback to invoke when the selected country changes, picked in the list, detected from the number or set by the value.  `(countryChange)`  gives the ISO code alone. |
| onComplete | event: PhoneInputCompleteEvent | Callback to invoke when the typed number becomes complete: valid, with the maximum length of its country. |
| onFocus | event: FocusEvent | Callback to invoke when the component receives the focus. |
| onBlur | event: FocusEvent | Callback to invoke when the component loses the focus. |

### Templates

| Name | Type | Description |
|------|------|-------------|
| country | TemplateRef<PhoneInputCountryTemplateContext> | Custom content of a country in the list. |
| selectedcountry | TemplateRef<PhoneInputCountryTemplateContext> | Custom content of the selected country. |

### Methods

| Name | Parameters | Return Type | Description |
|------|------------|-------------|-------------|
| focus |  | void | Moves the focus to the number input. |
| clear |  | void | Empties the number and keeps the country. |

## Pass Through Options

| Name | Type | Description |
|------|------|-------------|
| host | PassThroughOption<HTMLElement, I> | Used to pass attributes to the host's DOM element. |
| root | PassThroughOption<HTMLElement, I> | Used to pass attributes to the root's DOM element. |
| pcCountrySelect | SelectPassThrough | Used to pass attributes to the Select component of the country. |
| selectedCountry | PassThroughOption<HTMLSpanElement, I> | Used to pass attributes to the selected country shown in the Select. |
| country | PassThroughOption<HTMLSpanElement, I> | Used to pass attributes to the content of a country in the list. |
| flag | PassThroughOption<HTMLSpanElement, I> | Used to pass attributes to the flags. |
| countryName | PassThroughOption<HTMLSpanElement, I> | Used to pass attributes to the names of the countries in the list. |
| dialCode | PassThroughOption<HTMLSpanElement, I> | Used to pass attributes to the dial codes. |
| pcInput | InputTextPassThrough | Used to pass attributes to the InputText of the number. |

## Theming

### CSS Classes

| Class | Description |
|-------|-------------|
| p-phoneinput | Class name of the root element |
| p-phoneinput-country-select | Class name of the country Select |
| p-phoneinput-overlay | Class name of the overlay of the country Select |
| p-phoneinput-selected-country | Class name of the selected country |
| p-phoneinput-country | Class name of a country in the list |
| p-phoneinput-flag | Class name of a flag |
| p-phoneinput-country-name | Class name of the name of a country |
| p-phoneinput-dial-code | Class name of a dial code |
| p-phoneinput-input | Class name of the number input |

### Design Tokens

| Token | CSS Variable | Description |
|-------|--------------|-------------|
| phoneinput.selected.country.gap | --p-phoneinput-selected-country-gap | Gap between the flag and the dial code of selected country |
| phoneinput.flag.font.size | --p-phoneinput-flag-font-size | Font size of flag |
| phoneinput.overlay.min.width | --p-phoneinput-overlay-min-width | Min width of overlay |
| phoneinput.option.gap | --p-phoneinput-option-gap | Gap of option |
| phoneinput.option.dial.code.color | --p-phoneinput-option-dial-code-color | Dial code color of option |
| phoneinput.separator.color | --p-phoneinput-separator-color | Color of the separator after the preferred countries |

