Number Field

A numeric input element with increment and decrement buttons, and a scrub area.

API Reference

Installation

pnpm dlx cnippet@latest add number-field

Usage

import {
  NumberField,
  NumberFieldDecrement,
  NumberFieldGroup,
  NumberFieldIncrement,
  NumberFieldInput,
  NumberFieldScrubArea,
} from "@/components/ui/number-field"
<NumberField defaultValue={0}>
  <NumberFieldScrubArea label="Quantity" />
  <NumberFieldGroup>
    <NumberFieldDecrement />
    <NumberFieldInput />
    <NumberFieldIncrement />
  </NumberFieldGroup>
</NumberField>

Examples

For accessible labelling and validation, prefer using the Field component to wrap number fields. See the related example: Number field.

Sizes

With External Label

With Formatted Value

With Step

Form Integration