Genesis
@beta

NumberInput

NumberInput — a number with − and + buttons: the twin of genesis-ui-native's NativeNumberInput, with the same `value`, `min`, `max`, `step` and `precision`. The field is a `spinbutton` (↑ and ↓ step it, Page Up and Page Down by ten steps, Home and End go to the ends); typing "1,5" reads as 1.5 and "1,234" as 1234. Clamping, stepping and reading what was typed are genesis-core's, as on the phone. A typed number is passed on as it is typed only while it is inside `min` and `max`; one outside is clamped when the field is left or Enter is pressed, so typing "1" on the way to "15" with `min` 10 never sends 10. The ref is the input's, so a form library can register it with `name` and `onBlur`. It is the InputGroup with the buttons at its ends.

packages/ui/src/components/ui/number-input.tsx

Import
Subpath export: @marktiderman/genesis-ui
import { NumberInput } from "@marktiderman/genesis-ui";
Components
Auto-generated from TypeScript source via react-docgen-typescript.

NumberInput

NumberInput — a number with − and + buttons: the twin of genesis-ui-native's NativeNumberInput, with the same `value`, `min`, `max`, `step` and `precision`. The field is a `spinbutton` (↑ and ↓ step it, Page Up and Page Down by ten steps, Home and End go to the ends); typing "1,5" reads as 1.5 and "1,234" as 1234. Clamping, stepping and reading what was typed are genesis-core's, as on the phone. A typed number is passed on as it is typed only while it is inside `min` and `max`; one outside is clamped when the field is left or Enter is pressed, so typing "1" on the way to "15" with `min` 10 never sends 10. The ref is the input's, so a form library can register it with `name` and `onBlur`. It is the InputGroup with the buttons at its ends.

PropTypeDefaultDescription
onChange*(next: number) => void—
value*number—
aria-labelstring—The field's accessible name when no `<label htmlFor>` names it.
classNamestring—
disabledboolean—
idstring—
labels{ decrement?: string; increment?: string; } | undefined{}The stepper buttons' names. Default "Decrement" / "Increment".
localestring—The locale whose marks typed numbers use ("de-DE" reads "1.234,5"). Default: worked out from the text ("1,234" is 1234, "1,5" is 1.5), genesis-core's `parseNumberInput`.
maxnumber—
minnumber—
namestring—The field's name in a form.
onBlurFocusEventHandler<HTMLInputElement>—Called when the field is left, after a typed number is committed.
precisionnumber0Decimal places shown. Default 0.
readOnlyInputboolean—Keep the steppers but not typing.
stepnumber1Each press of − or +, and each arrow key. Default 1.
testIDstringnumber-input
Storybook
Storybook hosts the canonical visual reference with controls for every variant.