Skip to content

Early previewhamur is not on npm yet. The components are being built in the open, follow along on GitHub.

UIComponentsReact

Number Field

A field for a number, with buttons to step it up and down.

Built on the headless Number Field.See its API in Docs

Rendered by React 19.3.1

number-field.tsx

Installation

npx shadcn@4.23.0 add https://hamur.dev/r/react/number-field.json

It also adds utils. The app needs its setup first: Installation.

Usage

NumberFieldGroup holds the decrement button, the input and the increment button; NumberFieldScrubArea lets the reader drag its label to change the value. min, max, step and the format are the headless Number Field's.

import {
  NumberField,
  NumberFieldDecrement,
  NumberFieldGroup,
  NumberFieldIncrement,
  NumberFieldInput,
  NumberFieldScrubArea,
  NumberFieldScrubAreaCursor,
} from '@/components/ui/number-field'

Examples

Default

A quantity with steppers.

Its preview and code are at the top of the page.

shadcn/ui has no Number Field, so this item takes Base UI's component ID as its slug and one name per Base UI part. Its group is drawn as an Input Group's box, its input as an Input's text, and its steppers as ghost buttons.

API reference

The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Number Field's API reference.