Skip to content
nexubDesign System
v12.7.0

Components · Form & Input

Number Input

StableAdded v0.0.1 · updated v11.1.0

A numeric input with optional steppers. Limits apply when the field loses focus; `nullable` lets it be empty.

import { NumberInput } from '@nexub/react';
View as Markdown

Usage

Use it for
  • A quantity people type or step: seats, limits, percentages.

  • A value that may be empty (`nullable`) and must stay inside `min` and `max`.

Use something else for
  • On a page without React (server-rendered HTML, a plain `<form>`): use `<nx-number-input>` from `@nexub/elements`, the same rules as a web component.

  • Money: use MoneyInput. Phone numbers and codes: use a text input.

Playground

Props

size
TSX
<NumberInput defaultValue={0} />

Examples

Default

With range

Can be empty

`nullable`: cleared means null. The limits apply on blur.

No limit (null)

States

  • default
  • disabled
  • invalid
  • size="sm"
  • size="md"
  • size="lg"

Props

Props
PropTypeDefaultDescription
valuenumber—Controlled value. null (with nullable) shows an empty field.
nullablefalsefalseThe field can be empty: clearing it reports null, not 0, and a half-typed 2. or - stays while focused.
onValueChange((value: number) => void)—Called while typing (not yet clamped) and with the clamped value on blur, steppers and arrow keys. With nullable, null when cleared.
minnumber—Lowest value, applied on blur, steppers and arrow keys (never mid-typing, so 30 can be typed with a minimum of 15).
maxnumber—Highest value, applied the same way.
stepnumber | 'any'1Increment for steppers and arrow keys. 'any' allows any decimal (steppers then move by 1).
disabledboolean—Disables the input and its controls.
size'sm' | 'md' | 'lg''md'Controls font size and padding.
defaultValuenumber—
invalidboolean—
precisionnumber—
showSteppersbooleanfalse