ui

Number Field

A numeric input element with increment and decrement buttons, and a scrub area. Built with Base UI and Tailwind CSS. Copy-paste ready.

API Reference

Installation

Usage

API Reference

NumberField

Root component. Styled wrapper for NumberField.Root from Base UI.

NumberFieldGroup

Container for the input and buttons. Styled wrapper for NumberField.Group from Base UI.

NumberFieldInput

Input element for the number value. Styled wrapper for NumberField.Input from Base UI.

NumberFieldIncrement

Button to increment the value. Styled wrapper for NumberField.Increment from Base UI with plus icon.

NumberFieldDecrement

Button to decrement the value. Styled wrapper for NumberField.Decrement from Base UI with minus icon.

NumberFieldScrubArea

Draggable area for scrubbing the value. Styled wrapper for NumberField.ScrubArea from Base UI.

Examples

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

Sizes

Renders the sm, default, and lg size variants to show how the number field scales across layout contexts.

Disabled

Prevents all interaction while keeping the current value visible in the input.

With External Label

Associates an external Label with the number field via useId for accessible identification without Field.

With Scrub

Adds a NumberFieldScrubArea above the input so users can drag left/right to adjust the value — useful for large ranges.

With Range

Sets min and max constraints to clamp the value within a defined boundary, preventing out-of-range entries.

With Formatted Value

Applies a custom format function to display the value with a currency symbol, unit, or locale-specific formatting.

With Step

Sets a step value so each increment or decrement click moves the value by a fixed amount (e.g. 5 or 0.25).

Form Integration

Wraps the number field in Form and Field for label association, required validation, and a visible FieldError.

Percentage with Scrub

Uses format={{ style: "percent" }} with a 0–1 range and step={0.05}, rendered as a draggable scrub area for an opacity or volume control.

Shopping Cart Quantity

A compact product row pairing a thumbnail placeholder, name, price, and an inline NumberField for adjusting item count — common in cart and order summary UIs.

Typography Settings

Three labeled rows (font size, line height, letter spacing) each with a NumberFieldScrubArea and unit suffix, forming a compact typographic control panel.

Min/Max Budget Range

Two side-by-side currency-formatted fields (Min and Max) with a dash separator — ideal for price range filters in search or marketplace UIs.

Controlled with Reset

A useState-controlled field paired with a ghost icon button that restores the value to its default — useful for settings panels where users can undo edits.