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

Chapter 04 Fields

PIN input

A code sent by text message, one box per digit. Typing moves along, Backspace goes back, and pasting the code fills every box. On a phone the keyboard offers the code from the message, and the boxes take it all at once.

Use it in Angular
import { PinInputComponent } from '@okaapi-ui/angular';
// The value is the digits typed so far, as one string.

A verification code

complete fires once the last box is filled, so the code can be checked without a button.

Verification code

Sent to +20 10 1234 5678.

Angular
<ui-pin-input label="Verification code" formControlName="code" (complete)="verify($event)" />

A PIN

secret shows dots, for a number the person chose rather than one sent to them.

Card PIN
Angular
<ui-pin-input label="Card PIN" [length]="4" secret />

In Arabic

The boxes still run left to right, as the digits do.

رمز التحقق
Angular
<ui-pin-input label="رمز التحقق" [cellLabel]="cell" error="الرمز غير صحيح. أعد المحاولة." />

cell = (n: number, of: number) => `الرقم ${n.toLocaleString('ar-EG')} من ${of.toLocaleString('ar-EG')}`;

When to use something else

If you needUse
A passwordText field with type password
A phone numberPhone field

Inputs

NameTypeDefaultWhat it does
labelstring — Names the boxes as a group.
lengthnumber6How many digits.
secretbooleanfalseDots instead of digits, for a PIN.
cellLabel(n, of) => string`Digit ${n} of ${of}` from labelsEach box's name for screen readers. Translate it.
hint | errorstring — Help text, and the translated error that marks it invalid.
(complete)string — Every box is filled: the whole code.

Keyboard and screen readers

KeysWhat they do
A digit Fill the box and move to the next one.
Backspace In an empty box, go back to the one before.
Left or Right Move to the box before or after.
Home or End Go to the first or last box.
  • Pasting the code fills every box, and phones offer the code from the message.