Chapter 04 Fields
Phone field
A phone number with its country code. The number reads left to right in every language, Arabic digits are welcome, and the 0 people type before a mobile number out of habit is dropped. What the form gets is one international number, ready to send a text to.
import { PhoneFieldComponent, PHONE_COUNTRIES } from '@okaapi-ui/angular';
// The value is an E.164 number such as +201012345678, or null.A mobile number
Type 010 1234 5678 and the form gets +201012345678.
We text the delivery code here.
—
<ui-phone-field label="Mobile" country="EG" hint="We text the delivery code here." formControlName="phone" />Your own list
Pass the countries you serve, with their names in the reader's language.
<ui-phone-field label="رقم الجوال" country="SA" countryLabel="رمز الدولة" [countries]="gulf" />
gulf: PhoneCountry[] = [
{ code: 'SA', dial: '+966', name: 'السعودية' },
{ code: 'AE', dial: '+971', name: 'الإمارات' },
];When to use something else
| If you need | Use |
|---|---|
| Any other number | Number field |
| A one-time code sent by SMS | PIN input |
Inputs
| Name | Type | Default | What it does |
|---|---|---|---|
label | string | — | Names the number. |
country | string | EG | The country picked at first, by ISO code. A stored number picks its own. |
countries | PhoneCountry[] | PHONE_COUNTRIES | { code, dial, name }. ISO alpha-2 code supplies a flag, drawn the same on every system. The Arab world first, then the most common elsewhere. |
countryLabel | string | Country code from labels | Names the list for screen readers. Translate it. |
hint | error | placeholder | string | — | Help text, the translated error, an example. |
Keyboard and screen readers
| Keys | What they do |
|---|---|
| Up or Down | On the country button, open the list of countries. |
| Up or Down or Home or End | In the list, move through the countries. |
| Enter or Space | Pick the country. |
| Escape or Tab | Close the list. |
- The country button is read with the country and its code; the number reads left to right in every language.