Skip to content
Alea0.1

Forms

NumberField

Numbers with steppers, limits and locale formatting for currency, percent and units.

Ant Design: InputNumber

import { NumberField } from '@alea/ui';

Examples

Number field

Steppers, limits and keyboard steps.

Formats

Currency, percent and units, in the person's locale.

Props

NumberField props

A number input with steppers, min, max, step and locale formatting (currency, percent, units).

PropTypeDefaultDescription
descriptionReactNode-Help text under the field.
errorMessageReactNode | ((v: ValidationResult) => ReactNode)-Error text, or a function of the validation result. Shown when invalid.
labelReactNode-The visible label. Use aria-label instead only when the context makes it obvious.
placeholderstring-Placeholder text.
showOptionalboolean-Shows "(optional)" after the label.
showStepperbooleantrueShows the − and + buttons. Default true.
size"sm" | "md" | "lg"'md'sm 32 px, md 44 px (default), lg 48 px.

Accessibility

  • The input is a text field with the formatted value; the steppers are labelled Increase and Decrease.

Keyboard

KeyDoes
Arrow Up / DownSteps by step
Page Up / DownSteps by ten steps
Home / EndJump to min / max

Do and don't

Do

  • Set minValue and maxValue when there are real limits.

Don't

  • Don't use it for numbers that are not quantities (phone, card, ZIP): use TextField with inputMode.
Tested with axe, keyboard and screen reader roles