Skip to content
Okaapiأوكابي
Framework for the code
Theme
Okaapi on GitHub

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.

Use it in Angular
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.

—

Angular
<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.

Angular
<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 needUse
Any other numberNumber field
A one-time code sent by SMSPIN input

Inputs

NameTypeDefaultWhat it does
labelstring — Names the number.
countrystringEGThe country picked at first, by ISO code. A stored number picks its own.
countriesPhoneCountry[]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.
countryLabelstringCountry code from labelsNames the list for screen readers. Translate it.
hint | error | placeholderstring — Help text, the translated error, an example.

Keyboard and screen readers

KeysWhat 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.