Chapter 04 Fields
Number field
A number with − and + either side. Type it, in Latin or Arabic digits, or step it with the buttons, the arrow keys, or Page Up and Down for ten steps. On leaving the field it stays inside its limits and is written in the reader's language.
import { NumberFieldComponent } from '@okaapi-ui/angular';
// The value is a number, or null when empty.A quantity
The number is the one Tab stop; the buttons are for the pointer, as Up and Down do the same.
Up to 12 at one table.
<ui-number-field label="Guests" [min]="1" [max]="12" hint="Up to 12 at one table." formControlName="guests" />Money
formatOptions takes any Intl number format: currency, units, or a fixed number of decimals.
<ui-number-field
label="Budget"
[min]="0"
[step]="50"
[formatOptions]="{ style: 'currency', currency: 'EGP' }"
formControlName="budget"
/>In Arabic
<ui-number-field label="عدد الضيوف" locale="ar-EG" decrementLabel="إنقاص" incrementLabel="زيادة" [min]="1" [max]="12" />When to use something else
| If you need | Use |
|---|---|
| A rough amount on a scale | Slider |
| A code such as an ID or a card number | Text field |
| A price with a currency beside it | Input group |
Inputs
| Name | Type | Default | What it does |
|---|---|---|---|
label | string | — | Names the field. |
min | max | number | — | Limits. Stepping stops at them; typing is pulled back on leaving. |
step | number | 1 | One press. Page Up and Down move ten. |
formatOptions | Intl.NumberFormatOptions | — | Currency, units or decimals. With percent the value is the fraction, so step 0.01. |
hint | error | string | — | Help text, and the translated error that marks it invalid. |
decrementLabel | incrementLabel | string | Decrease | Increase | Names the buttons. Translate them. |
locale | string | LOCALE_ID | Digits and separators: ar-EG writes Arabic digits. |
Keyboard and screen readers
| Keys | What they do |
|---|---|
| Up or Down | Step up or down by one step. |
| Page Up or Page Down | Step by ten steps. |
| Home or End | Go to the lowest or highest value, when there is one. |
| Enter | Keep the value inside its limits and write it out. |
- Latin and Arabic digits are both taken; the − and + buttons are named.