Skip to content

InputNumber ​

A number with − and + buttons, e.g. a year group, a quantity or an amount.

Open in Storybook to try every prop.

When to use ​

  • Numbers people adjust in small steps, or that have a range: year groups, quantities, amounts of money.

When not to use ​

  • Numbers that are really identifiers (phone numbers, student IDs, postcodes): use Input. They're never added up, and leading zeros matter.
  • A one-time code: use InputCode.

Anatomy ​

PartRequiredNotes
label, helper, message—As every field (FormField).
boxYesFormField's box, laid out as [ − | value | + ].
− / + buttonsYes36px square ends of the box, divided from the value by a black 15% line, like a basic Button.
valueYesCentred, tabular figures, formatted for the locale.

Properties ​

PropertyTypeDefaultDescription
modelValuenumber | undefined—The number; undefined when empty.
labelstring—Required.
helper / helperPlacementstring / below | icon— / belowAs every field.
errorText / status / statusText—As every field.
min / maxnumber—The range. The − or + button is disabled at either end.
stepnumber1How much − / + and the arrow keys change the value.
formatOptionsIntl.NumberFormatOptions—How it's shown, e.g. { style: 'currency', currency: 'GBP' }.
localestringbrowser'sLocale for formatting.
disabledbooleanfalse40% opacity, not editable.

States ​

StateAppearanceNotes
At min / maxThat end's icon at 40% opacity, button disabled.
FocusedFocus ring around the box.
Error / successBox border and message coloured.
Disabled40% opacity.

Behaviour ​

  • Up / Down arrows step by step; Page Up / Page Down by more; Home / End jump to min / max.
  • Typed values are kept within min and max when the field is left.
  • The value is formatted when the field is left, e.g. "12.5" becomes "£12.50".

Accessibility ​

  • A spinbutton named by the label. Its value text is the number as shown (e.g. "9" or "£12.50"); without it, VoiceOver reads a value with a range as a percentage.
  • The − / + buttons are labelled "Decrease" and "Increase".

Platform adaptation ​

PlatformImplementationDifferences
Web / desktop (Vue)InputNumber.vueReka UI NumberField.
iOS (SwiftUI)—TextField with a number format and a Stepper beside it.
Android (Compose)—Number TextField with − / + icon buttons.

Tokens used ​

TokenUsed for
color-focusFocus ring
color-red / color-greenError / success

Released under the PolyForm Noncommercial License 1.0.0.