Form input

Number input

Predictable numeric models, decimal-safe stepping, and consistent M3 controls.

Number input at a glance

A text field that holds a number: it parses the locale-formatted draft the user types, steps by `step`, and writes a clean `number | null` to the model only once the draft parses.

  • A number, not a stringThe model is `number | null`. Whatever is half-typed — a grouping separator, a trailing decimal comma, a lone minus — lives in a draft and reaches the model only when it parses.
  • Locale-aware`locale` drives both formatting and parsing, so `1 234,5` works in ru-RU and `1,234.5` in en-US. `useGrouping` switches the separators off.
  • Decimal-safe steppingSteps are counted at the field's `precision`, inferred from `step` when omitted, so 0.1 + 0.2 lands on 0.3 and not on a floating-point tail.

A quick look

The default field: filled, a floating label, and stepper zones at both edges.

01

Start with a label and bounds

`label`, `min`, `max` and `step` cover most fields. Reach for `precision` and `locale` only when the defaults do not match the data.

02

Commit, then clamp

`clamp` pulls a committed value back inside `min`/`max` — never per keystroke, so typing 150 on the way to 15 is not fought.