A number with a range, a step and a unit. Type freely, kept in range on blur; 44 px buttons; arrow keys, Shift, PageUp/PageDown, Home/End.
Number field speed
Install
npx shadcn add @syncrobotic/number-field Also installs: lucide-react, @syncrobotic/cn, @syncrobotic/input-group
Overview
More examples
States and real uses. Each example is also a Storybook story and a visual regression test.
Number field kinds
Number field states
Usage rules
- The value and its unit are one reading, centred between − and +: write the unit with
unit, not in the label. - For a number with a range and a unit: speed, thresholds, intervals. For a free number with no range, Input with inputMode="numeric" is enough.
- Never block typing. The value is kept in range when the field loses focus, and the hint says the range.
- ↑↓ step, Shift or PageUp/PageDown step by largeStep, Home/End go to the limits. The buttons are for touch and skip the Tab order.
Changelog
- 0.17.22026-11-19A comment says where keyboard focus shows instead of the removed outline (no change in behaviour); checked by lint:rules.
- 0.15.02026-11-19The value and its unit are one reading, centred between − and + ("20 %"), instead of the value in the middle and the unit by the + button; the value is as wide as its digits. Angles sit on the number ("-2.5°"). A press anywhere in the middle puts the caret in the value.
- 0.10.02026-11-18Disabled keeps its words readable: a grey field (bg-muted, muted text) on controls with a surface, solid disabled ink on items and icons; no more 50 % opacity, which washes text out in sunlight.