Components / Inputs
NumberInput
Number field with − and + buttons (MUI Base's NumberInput). Arrow keys step; typing is clamped on blur.
import { NumberInput } from "@stylhero/ui";
Example
Code
import { NumberInput } from "@stylhero/ui";
function NumberInputExample() {
return <NumberInput label="Quantity" defaultValue={1} min={1} max={10} />;
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
className |
string |
- | |
defaultValue |
number |
0 |
|
disabled |
boolean |
- | |
error |
ReactNode |
- | |
hint |
ReactNode |
- | Help text under the field. Replaced by error when set. |
id |
string |
- | |
label |
ReactNode |
- | |
max |
number |
Infinity |
|
min |
number |
-Infinity |
|
name |
string |
- | |
onBlur |
(e: FocusEvent<HTMLInputElement>) => void |
- | Runs when the text box loses focus, after a typed value is committed (react-hook-form's field.onBlur). |
onValueChange |
(value: number) => void |
- | |
step |
number |
1 |
|
value |
number |
- |
Takes a ref.
Keyboard
| Key | Does |
|---|---|
| ArrowUp / ArrowDown | Add / subtract step |
| Enter | Commits what you typed (also on blur) |
Accessibility
- The text box has
role="spinbutton"witharia-valuenow,-minand-max. The + and − buttons ("Increase", "Decrease") are for pointer users and stay out of the Tab order: the arrow keys do the same.
Generated from src/components/NumberInput.tsx. Something wrong or missing? Open an issue.