What the component guarantees
- A native number field. It renders
<input type="number">withmin,maxandstep, so a reader announces it as a spin button and the arrow keys step it natively. - A label tied to the field through
forand the field's id. - Validation a reader hears. With
error, the field carriesaria-invalid="true"andaria-describedbypoints at the visible message by its id ({id}-error,{id}-warning,{id}-helper). A message present on first render is read on focus and not announced on load; one that appears or changes later mounts withrole="alert"(error) orrole="status"(warning). The status icon inside the field repeats the message for sighted users and isaria-hidden, so a reader hears it once. - Named steppers. The
−and+buttons are ghost, icon-onlyNbButtons named "Decrease" and "Increase" through theirlabel, which is also their tooltip, and they do not take focus from the field on a mouse press. They are out of the tab order, as in Carbon: the arrow keys on the field already step the value, so a keyboard user loses nothing and skips two stops per field. Atminormaxthe stepper that cannot go further is drawn disabled. - Text a phone will not zoom, at least 16px on a phone touch screen.
- Tested in
tests/NumberInput.test.tsandtests/fieldValidationAria.test.ts, and by axe intests/axe.test.ts.
Keyboard
| Key | Action |
|---|---|
| ↑ ↓ | Steps the value by step (the browser's own) |
| Enter | Commits the typed value (the field blurs) |
| Tab | Moves to the steppers, then out |
What you own
- A label. Without
labelthe field has no name. - Units. "Seats" or "Price (EUR)" in the label; a unit drawn only beside the field is not read with it.
- Error text that says the range, "Between 1 and 50", rather than "Invalid".
Known gaps
- Enter blurs the field to commit it, so focus leaves the field. A keyboard user presses Shift+Tab to return.
- No manual screen reader pass has been recorded for this component.