---
title: "Number Field"
description: "A field for one number, with minus and plus buttons. Arrow keys step it, a drag on the label changes it, and it formats the number for the locale."
url: https://gelatinui.com/components/number-field
markdown_url: https://gelatinui.com/components/number-field.md
access: free
install: "npx shadcn@latest add @gelatin-ui/number-field"
registry_item: https://gelatinui.com/r/number-field.json
version: "2026-11-08"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Number Field

> A field for one number, with minus and plus buttons. Arrow keys step it, a drag on the label changes it, and it formats the number for the locale.

Page: https://gelatinui.com/components/number-field

## When to use it

Best for: One number with steps and limits: a quantity, a price, or a size.

- Set `min`, `max`, and `step`.
- Pass `format` for a currency, a percent, or a unit.
- Add `NumberFieldScrubArea` for a drag on the label.

## When not to use it

- For a number that is a position in a range, use a [Slider](https://gelatinui.com/components/slider.md).
- For a code or a phone number, use a plain field: they are not numbers.

## Notes for agents

- The value is a number, or `null` when empty.
- `step`, `smallStep` (Alt), and `largeStep` (Shift) set the arrow-key steps.
- With no `allowOutOfRange`, it clamps to `max` on blur.
- Give the group controls an `aria-label`, such as "Fewer" and "More".
- All Base UI props pass through.

## Anatomy

```text
NumberField
├─ NumberFieldScrubArea (0..n)
├─ NumberFieldScrubAreaCursor (0..n)
├─ NumberFieldGroup (0..n)
├─ NumberFieldInput (0..n)
├─ NumberFieldDecrement (0..n)
└─ NumberFieldIncrement (0..n)
```

## API reference

### NumberField

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

Also takes every prop of Base UI `NumberField.Root`: https://base-ui.com/react/components/number-field

### NumberFieldScrubArea

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

Also takes every prop of Base UI `NumberField.ScrubArea`: https://base-ui.com/react/components/number-field

### NumberFieldScrubAreaCursor

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### NumberFieldGroup

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `"default" \| "lg" \| "sm" \| "xs"` | "default" |  |
| `className` | `string` |  |  |

### NumberFieldInput

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

Also takes every prop of Base UI `NumberField.Input`: https://base-ui.com/react/components/number-field

### NumberFieldDecrement

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### NumberFieldIncrement

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| NumberField | `number-field` |  |  |  |
| NumberFieldScrubArea | `number-field-scrub-area` | `data-direction`, `data-disabled`, `data-readonly` |  |  |
| NumberFieldScrubAreaCursor | `number-field-scrub-area-cursor` |  |  |  |
| NumberFieldGroup | `number-field-group` | `data-scrubbing`, `data-size` |  |  |
| NumberFieldInput | `number-field-input` | `data-size` |  |  |
| NumberFieldDecrement | `number-field-decrement` | `data-readonly` |  |  |
| NumberFieldIncrement | `number-field-increment` | `data-readonly` |  |  |

## Usage

Compose the group.

```tsx title="quantity-field.tsx"
import {
  NumberField,
  NumberFieldDecrement,
  NumberFieldGroup,
  NumberFieldIncrement,
  NumberFieldInput,
} from "@/components/ui/number-field";

export function QuantityField() {
  return (
    <NumberField defaultValue={2} min={0} className="w-40">
      <NumberFieldGroup>
        <NumberFieldDecrement aria-label="Fewer" />
        <NumberFieldInput aria-label="Quantity" />
        <NumberFieldIncrement aria-label="More" />
      </NumberFieldGroup>
    </NumberField>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/number-field
```

It adds 17 registry items: 14 files, 2755 lines, and the npm packages `@base-ui/react`, `@phosphor-icons/react`, `clsx`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Input Group](https://gelatinui.com/components/input-group.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Input Group](https://gelatinui.com/components/input-group.md)
- [Slider](https://gelatinui.com/components/slider.md): Pick Slider when the number is a position in a range that people drag to.
- [Form](https://gelatinui.com/components/form.md)
- [Input](https://gelatinui.com/components/input.md): Pick Input for text that only looks like a number, such as a code or a phone number.

## Keyboard

| Keys | Action |
| --- | --- |
| Up Arrow, Down Arrow | Steps by `step`. Shift steps by `largeStep`, and Alt by `smallStep`. |
| Page Up, Page Down | Steps by `largeStep`. |
| Home, End | Goes to `min` or `max`. |

## Accessibility

The input is a `spinbutton` for the keyboard and screen readers.

Each stepper keeps a 44px touch target. To the eye it stays small.
