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

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.

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

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

Angular
<ui-number-field
  label="Budget"
  [min]="0"
  [step]="50"
  [formatOptions]="{ style: 'currency', currency: 'EGP' }"
  formControlName="budget"
/>

In Arabic

Angular
<ui-number-field label="عدد الضيوف" locale="ar-EG" decrementLabel="إنقاص" incrementLabel="زيادة" [min]="1" [max]="12" />

When to use something else

If you needUse
A rough amount on a scaleSlider
A code such as an ID or a card numberText field
A price with a currency beside itInput group

Inputs

NameTypeDefaultWhat it does
labelstring — Names the field.
min | maxnumber — Limits. Stepping stops at them; typing is pulled back on leaving.
stepnumber1One press. Page Up and Down move ten.
formatOptionsIntl.NumberFormatOptions — Currency, units or decimals. With percent the value is the fraction, so step 0.01.
hint | errorstring — Help text, and the translated error that marks it invalid.
decrementLabel | incrementLabelstringDecrease | IncreaseNames the buttons. Translate them.
localestringLOCALE_IDDigits and separators: ar-EG writes Arabic digits.

Keyboard and screen readers

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