Skip to content

NumberInput ​

NumberInput is the input of a number.

When to use ​

Use it for an exact number, with its unit. It is empty when value is null; a placeholder can say what empty means (for example Auto). Only short values take a fixed width, one of 6, 8 or 12rem; without width it fills its container. digits sizes it to its value instead: the input is as many characters wide as the longest value (or the placeholder, when it is longer), and the unit follows it; digits wins over width.

Props ​

PropDefaultDescription
valuenullThe number, or null when empty (bindable)
unitA unit on the right inside the control
min, maxThe limits
stepThe step; any takes decimals
placeholderShown while it is empty
width6rem, 8rem or 12rem
digitsThe characters of the longest value; the input is that wide
ariaLabelThe accessible name without a Field
idThe id of the input
errorfalseThe line turns red
disabledfalseCannot be focused or changed
readonlyfalseCan be focused and selected, not changed
oninputEvery key stroke
onchangeThe committed value

Contract ​

It is the control of a TextInput. The number is aligned to the end, with figures of equal width, and the unit is muted on the right inside the control, trimmed to its ink. The browser's spin buttons are removed, so they take no room; the arrow keys still step the value.

Example ​

NumberInput

Released under the Apache-2.0 license.