Skip to main content
Urbicon UI

NumberInputbeta

Numeric input with steppers, a clamped range, and decimal precision. It builds on Input, so its sizes, variants, and error/helper display carry over.

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 common case: 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; 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. A few Input props are held back: the raw string value, the fixed type/inputmode, the numeric event handlers, and clearable. Input's clear button would overwrite the numeric value with its own string, so NumberInput leaves it out.

rightIcon puts your own adornment where the stepper sits. The Arrow keys still step, but the +/− buttons are gone, so pair it with hideStepper or add your own controls. See the global Customization guide 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 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 steps 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

35 props
31 props
Prop
Type
Default
Description

05 Types

Local type definitions used by this component.

11 types
Name
Kind
Category
Used by
Description

06 Installation

Import

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