import { Label } from "@/components/ui/label"
import {
NumberField,
NumberFieldDecrement,
NumberFieldIncrement,
NumberFieldInput,
} from "@/components/ui/number-field"
export default function Demo() {
return (
<div className="flex flex-col gap-10 p-6">
<div className="flex flex-col gap-2">
<Label htmlFor="quantity">Quantity</Label>
<NumberField id="quantity" name="quantity" defaultValue={1} min={1}>
<NumberFieldDecrement aria-label="Decrease quantity" />
<NumberFieldInput />
<NumberFieldIncrement aria-label="Increase quantity" />
</NumberField>
</div>
</div>
)
}Installation
npx shadcn@latest add @fulldev/number-field
Usage
import {
NumberField,
NumberFieldDecrement,
NumberFieldIncrement,
NumberFieldInput,
} from "@/components/ui/number-field"
<NumberField name="quantity" defaultValue={1} min={1}>
<NumberFieldDecrement />
<NumberFieldInput aria-label="Quantity" />
<NumberFieldIncrement />
</NumberField>
NumberField is the Base UI
Number Field in the
shadcn/ui input group look. Set name, defaultValue or value, min, max,
step and format on NumberField. The buttons are named “Decrease” and
“Increase”; pass an aria-label in your language.