Skip to main content
Urbicon UI

NumberInputbeta

Numeric input with steppers, a clamped range, and decimal precision. Built on Input, so it inherits its sizes, variants, and validation surface.

Playground

Use the steppers or the arrow keys.
<NumberInput
  helper="Use the steppers or the arrow keys."
  label="Quantity"
  max={10}
  min={0}
  precision={0}
/>

01 Examples

Quantity in a line item

The canonical use: a bounded integer the user nudges rather than types. min keeps it out of negatives, max caps it at what is in stock, and the stepper clamps immediately instead of waiting for blur.
<NumberInput label="Quantity" bind:value={quantity} min={0} max={99} step={1} />

Decimal rate with fixed precision

step and precision are separate: step is how far one press moves, precision is how many decimals are displayed and rounded to. Without precision the value shows as typed and the step's own decimals drive the rounding.
Between 0 and 1
<NumberInput
  label="Commission rate"
  bind:value={rate}
  min={0}
  max={1}
  step={0.05}
  precision={2}
  helper="Between 0 and 1"
/>

Without the stepper

hideStepper removes the buttons but not the behaviour — Arrow keys and the wheel still step. Useful in a dense row where two more hit targets per field would crowd the layout.
<NumberInput label="Servings" bind:value={servings} min={1} max={12} hideStepper />

02 Customization

NumberInput wraps <Input>, so size, variant, label, helper, error and the Input slotClasses keys all behave exactly as they do there. What it does not forward is deliberate: the numeric event handlers, the raw string value, the fixed type/inputmode, and clearable — Input's clear button would replace the stepper and write only Input's internal string, drifting the numeric model out of sync.

rightIcon replaces the stepper with an adornment of your own. Pair it with hideStepper or supply your own controls — otherwise the field loses its increment affordance while keeping the keyboard one. See Customization for the general contract.

For money use CurrencyInput instead: it stores minor units, so summing and comparison stay exact. NumberInput's values are plain numbers and carry the usual float caveats.

03 Accessibility

Spinbutton semantics

The field is a role="spinbutton" carrying aria-valuenow, aria-valuemin and aria-valuemax, so assistive tech announces both the current value and the range it sits in.

Keyboard

/ step by step and clamp immediately. Typing is free-form while focused — a leading - and a single decimal separator (. or ,) are both accepted — and the value clamps to the range on blur.

The steppers stay out of the tab order

Both stepper buttons carry aria-hidden and tabindex="-1". The spinbutton role already exposes increment and decrement on the field itself, so the buttons are the pointer affordance for what the Arrow keys do — not a second pair of tab stops.

Numeric keyboard on mobile

inputmode="decimal" is fixed, so mobile keyboards open the numeric pad with a decimal separator rather than the full alphabetic layout.

The wheel only steers a focused field

Wheel stepping is gated on focus. An unfocused field scrolled past in a long form would otherwise change its value while the user is only trying to reach the bottom of the page.

04 API Reference

33 props
31 props
Prop
Type
Default
Description

05 Types

Local type definitions used by this component.

9 types
Name
Kind
Category
Used by
Description

06 Installation

Import

import { NumberInput } from '@urbicon-ui/blocks';