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
@marktiderman/genesis-uiimport { NumberInput } from "@marktiderman/genesis-ui";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.
| Prop | Type | Default | Description |
|---|---|---|---|
| onChange* | (next: number) => void | — | |
| value* | number | — | |
| aria-label | string | — | The field's accessible name when no `<label htmlFor>` names it. |
| className | string | — | |
| disabled | boolean | — | |
| id | string | — | |
| labels | { decrement?: string; increment?: string; } | undefined | {} | The stepper buttons' names. Default "Decrement" / "Increment". |
| locale | string | — | 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`. |
| max | number | — | |
| min | number | — | |
| name | string | — | The field's name in a form. |
| onBlur | FocusEventHandler<HTMLInputElement> | — | Called when the field is left, after a typed number is committed. |
| precision | number | 0 | Decimal places shown. Default 0. |
| readOnlyInput | boolean | — | Keep the steppers but not typing. |
| step | number | 1 | Each press of − or +, and each arrow key. Default 1. |
| testID | string | number-input |