Number Input
Native number field with −/+ buttons: arrow keys, min/max/step validation and form submit from the platform; clamps on blur, rounds to the step's precision.
$29.00 · max 10 per order
"use client";import { useState } from "react";import { Field } from "@/components/ui/field";import { NumberInput } from "@/components/ui/number-input";export function CartQuantity() { const [qty, setQty] = useState(1); return ( <Field label="Quantity"> <NumberInput value={qty} onValueChange={setQty} min={1} max={10} name="qty" /> </Field> );}<NumberInput>
Native number field (ArrowUp/Down, form submit, min/max validation) with −/+ buttons, e.g. a cart quantity. Buttons are pointer helpers (tabIndex -1); keyboard users use the arrows.
defaultValuedefault0numberNumber at first render (uncontrolled).
maxnumberHighest value.
minnumberLowest value.
onValueChange(value: number) => voidCalled with the new number.
stepdefault1numberAmount the buttons and Up/Down change it by.
valuenumberControlled number; pair with
onValueChange.
| Prop | Type | Default |
|---|---|---|
defaultValueNumber at first render (uncontrolled). | number | 0 |
maxHighest value. | number | — |
minLowest value. | number | — |
onValueChangeCalled with the new number. | (value: number) => void | — |
stepAmount the buttons and Up/Down change it by. | number | 1 |
valueControlled number; pair with | number | — |
Also accepts every <input> prop.
* required. Every component also takes className.