Number input
FormsA number field with readable formatting, a native editing caret and expressive stepping.
Try it
Add to your project
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/number-input.jsonThe command includes the component’s shared dependencies. Your project keeps editable source files.
Include the complete example
This example also composes button, typography. Install its parts together:
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/number-input.json https://luv-jeri.github.io/cojeev-ui/r/button.json https://luv-jeri.github.io/cojeev-ui/r/typography.jsonUsing number input
Use defaultValue for internal state or value/onValueChange for controlled values. null represents an empty field.
Set min, max and step for adjustments. Editing uses a native text input with decimal input mode; blur and Enter normalize valid values, while Escape restores the current value.
Choose locale and Intl.NumberFormatOptions for display. The animated formatted layer gives way to the real input while editing.
Choose count, roll or steps for value transitions. The input ref targets the actual input; className and style apply to the outer field.
API
Compose the exported parts below. The prop types are read from the React source during the registry build.
Native element or underlying primitive props are inherited where declared, including accessible labels, event handlers and refs.
NumberInputProps
| Prop | Type | Required |
|---|---|---|
value | number | null | No |
defaultValue | number | null | No |
onValueChange | (value: number | null) => void | No |
min | number | No |
max | number | No |
step | number | No |
locale | string | No |
format | Intl.NumberFormatOptions | No |
treatment | AnimatedNumberProps["treatment"] | No |
duration | number | No |
decrementLabelAccessible labels for the two native step buttons. | string | No |
incrementLabel | string | No |
Accessibility
Associate a Label with id, or supply aria-label. The native input exposes spinbutton values and supports ArrowUp/ArrowDown.
Both step buttons have accessible labels and respect disabled/readOnly and bounds. Quiet settings show final values without motion.
States and appearance
For conditional content, keep a MotionPresence boundary around keyed MotionSurface children. The shared entrance and exit states work with native primitives and respect your motion preference.
Try pointer and keyboard interaction, and switch the appearance control in the navigation to compare light and dark mode. Motion respects reduced motion preferences.