ui-kit0.0

Forms

Number input

Bounded numbers with step buttons.

Usage

A spinbutton that looks like our Input, with − and + buttons, min, max and step. The value is a real number (or null when the field is empty), never a string.

5 seats at $12 = $60 per month.

When to use

  • Small counts and amounts people nudge up and down: seats, quantity, guests, discounts.
  • Money and percentages, where the shown text (€1,249.00, 15%) differs from the stored number.

Not for: phone numbers, postcodes, card numbers or ids (use a text input), or picking a value from a wide range (use a slider).

Currency and locale

format is number, currency or percent, shown with Intl.NumberFormat in the given locale. The typed text is parsed on blur (and on Enter) in the same locale: group separators, symbols and a trailing % are ignored. Unreadable text is dropped and the previous value returns. Pass locale explicitly so server and client render the same text.

Type any amount, such as 1,249.5. It is formatted when you leave the field.

Stored value: 1249

Percent values are fractions, like Intl: 0.15 shows as 15%, so one percentage point is step={0.01}. Mouse-wheel stepping is opt-in with allowWheel, and only works while the field is focused.

One step is one percentage point. Scroll over the field while it is focused to change it.

Buttons and sizes

Buttons sit inside the field, are attached as segments, or are hidden with none. A button disables itself at its bound. Hold a button to repeat; the longer you hold, the faster and bigger the steps.

API

NumberInput

PropTypeDefaultDescription
value / defaultValuenumber | nullnullControlled / initial value. null is an empty field.
onValueChange(value: number | null) => void—Called when a value is committed: step, key, wheel, blur or Enter. Not on each keystroke.
min / maxnumber—Bounds. Values are clamped; the buttons disable at them.
step / largeStepnumber1 / step × 10Arrow and button step; PageUp / PageDown step.
format'number' | 'currency' | 'percent''number'How the value is displayed and parsed.
locale / currencystring—BCP 47 tag and ISO 4217 code ("en-IE", "EUR").
minimumFractionDigits / maximumFractionDigitsnumber—Override the decimals shown.
controls'inside' | 'attached' | 'none''inside'Where the − and + buttons go.
allowWheelbooleanfalseChange the value with the wheel while focused.
holdToRepeatbooleantrueRepeat and accelerate while a button is held.
size'sm' | 'md' | 'lg''md'Height 32 / 36 / 44px.
incrementLabel / decrementLabelstring'Increase' / 'Decrease'Accessible names of the buttons.
namestring—Submits the raw number through a hidden input.
groupClassNamestring—Class for the surrounding group; className goes on the input.
...propsInputHTMLAttributes—Forwarded to the input (placeholder, disabled, readOnly, aria-*), including ref.

Keyboard

KeyAction
Up / DownIncrease or decrease by one step. Shift makes it ten steps.
PageUp / PageDownIncrease or decrease by ten steps (or largeStep).
Home / EndJump to min / max, when they are set.
EnterCommits the typed text. In a form it still submits.
TabCommits on leaving. The − and + buttons are not tab stops.

Accessibility

  • The input has role="spinbutton" with aria-valuenow, aria-valuemin, aria-valuemax and aria-valuetext (the formatted text).
  • Keyboard users and screen readers use the arrow keys; the buttons are for pointers and stay out of the tab order but remain clickable by assistive technology.
  • Inside a Field the id, aria-describedby, aria-invalid, required and disabled state are wired automatically.
  • On touch devices the text is 16px, so iOS Safari does not zoom on focus.

Motion

  • Border and ring transition over 150ms; inside buttons press to .94 on the snappy spring.
  • The number changes instantly: it is the information, so it is not animated.
  • Reduced motion drops the press scale; hover tints stay on fine pointers only.