Logobaseui-cn

Number Field

A numeric input with increment and decrement buttons.

Newformprimitiveinteractive
Loading preview...

Installation

npx baseui-cn add number-field

Usage

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

Examples

Basic

A number field without a label or constraints.

Loading preview...

Sizes

Available in sm, default, and lg sizes.

Loading preview...

Min and max

Use min and max to constrain the value range.

Loading preview...

Step

Use step to control the increment amount. Fractional steps are supported.

Loading preview...

Currency format

Use the format prop with { style: "currency", currency: "USD" } for formatted display.

Loading preview...

Spinner buttons

A compact variant with stacked chevron up/down buttons on the right side.

Loading preview...

Disabled

Loading preview...

API

NumberField

PropTypeDefaultDescription
size"sm" | "default" | "lg""default"Height and font-size scale shared with all child sub-components via context

NumberFieldGroup, NumberFieldDecrement, NumberFieldIncrement, and NumberFieldInput all inherit size from the parent NumberField context. Pass size directly to any of them to override locally.

NumberFieldScrubArea

PropTypeDefaultDescription
labelstringrequiredAccessible label text for the scrub cursor region

API Reference

See the Base UI NumberField documentation for the full API reference, including all props, data attributes, and CSS classes.