Number Field
A specialized input for numeric values with increment/decrement controls.
Installation
pnpm dlx shadcn@latest add @columbus/number-fieldUsage
import {
NumberField,
NumberFieldDecrement,
NumberFieldGroup,
NumberFieldIncrement,
NumberFieldInput,
NumberFieldScrubArea,
} from "@/components/ui/number-field";
<NumberField defaultValue={0}>
<NumberFieldScrubArea label="Quantity" />
<NumberFieldGroup>
<NumberFieldDecrement />
<NumberFieldInput />
<NumberFieldIncrement />
</NumberFieldGroup>
</NumberField>;NumberFieldScrubArea renders the label. Drag it left or right to change the
value. Without it, pass aria-label to NumberFieldInput, or point a
Label at the NumberField's id.
Arrow keys step the value. Hold Shift for steps of 10, or Alt for steps of 0.1.
Range
min and max limit the value and disable the buttons at each end.
Formatting
format takes Intl.NumberFormat
options, for currencies, percentages, and units.
Sizes
API reference
Each part wraps the matching Base UI Number Field part and accepts all its props. The buttons are labeled "Increase" and "Decrease" for screen readers.
NumberField
Prop
Type
NumberFieldScrubArea
Prop
Type