Number Input

GitHub

Numeric input with native minimum, maximum, and step support.

Installation

bash
pnpm dlx shadcn@latest add @cs/number-input

Usage

tsx
import { NumberInput } from "@/components/cs/number-input";
tsx
<NumberInput name="quantity" label="Quantity" min={1} step={1} />

API Reference

NumberInput

Numeric input with native minimum, maximum, and step support.

Props

NameTypeDefaultDescription
buttonOmit<DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> | undefined-Button displayed inside the input on the right.
defaultValuenumber-Initial numeric value for uncontrolled usage.
errorstring | null | undefined-Validation error message for the field.
iconReactNode-Icon displayed inside the input on the left.
inputClassNamestring | undefined-Additional classes applied to the native input control.
labelReactNode-Field label and fallback placeholder.
onValueChange(value: number | null) => void-Called with the parsed number or null when the field is cleared.
orientation"vertical" | "horizontal" | "responsive" | null | undefined-Layout of the field label and input control.
valuenumber-Controlled numeric value.

Dependencies