Number Field

Accessible spinbutton with locale-aware formatting, keyboard stepping, and hold-to-repeat stepper buttons. Built from scratch — no bits-ui primitive exists for this one.

Usage

Min / Max

Values are clamped on blur, Enter, and each stepper click. Home/End jump to the boundary.

Custom step

Buttons and arrow keys step by 5. Hold the button for continuous repeat.

Keyboard modifiers

Arrow keys step by 1. Shift+Arrow steps by 0.1 (fine). Page Up/Down steps by 10 (coarse).

Formatted — currency

On blur the value is formatted via Intl.NumberFormat. On focus the raw number is shown for unambiguous editing.

Formatted — percentage

Disabled

Prefix / Suffix

String decorators rendered as muted spans outside the input but inside the field.

°F

API reference

Scratch-built spinbutton — no bits-ui dependency. All props are native to this component.

PropTypeDescription
number (bindable)The current numeric value. Two-way bindable.
numberMinimum allowed value. Clamped on commit. Home key jumps here.
numberMaximum allowed value. Clamped on commit. End key jumps here.
numberDelta applied by stepper buttons and bare arrow keys.
numberDelta applied by Shift+ArrowUp/Down (fine control).
numberDelta applied by Page Up / Page Down (coarse control).
Intl.NumberFormatOptionsPassed to Intl.NumberFormat on blur. Omit for plain number display. Raw value shown on focus regardless.
stringBCP 47 locale tag (e.g. "en-US", "de-DE"). Defaults to the browser locale when omitted.
stringStatic string rendered before the input inside the field.
stringStatic string rendered after the input inside the field.
booleanDisables all interaction and drops opacity to 50%.
booleanPrevents text editing and stepper interaction. Value is still selectable.
(value: number) => voidCallback fired on blur or Enter after the value is clamped and committed.
HTMLInputElement | null (bindable)Two-way-bindable reference to the inner <input> element.
stringMerged onto the root wrapper via tailwind-merge.