VisorVisor
ComponentsForm

Number Input

A number input with increment/decrement buttons and min/max/step support.

Default

With Step

With Min/Max Bounds

Disabled

Invalid

With Field

Installation

npx visor add number-input

This copies two files into your project:

  • components/ui/number-input/number-input.tsx — the component
  • components/ui/number-input/number-input.module.css — the styles

Usage

import { NumberInput } from '@/components/ui/number-input/number-input';

<NumberInput defaultValue={1} min={0} max={10} />

Prefix and suffix

Same props, same treatment as Input: a currency symbol before the value, a unit after it, inside the same well as the steppers.

$
h

Skin and Glass

A theme reshapes the field and its buttons through the number-input hooks: fill, focused fill, edge colour, corners, height, the value's width, size and weight, and the buttons' size, inset, corners, ink, hover fill and icon size. Each falls back to the look above, so a theme that binds none of them draws NumberInput unchanged. The full list is on Component Tokens.

components:
  number-input:
    height: "54px"
    radius: "12px"
    value-width: "72px"
    value-font-size: "22px"
    value-font-weight: "640"
    button-size: "40px"
    button-inset: "7px"
    button-radius: "50%"
    icon-size: "20px"

Glass is off by default. Inside data-glass="on" (see Glass), the field takes the glass layer's control values: its fill, a brighter fill on focus, its ring as the edge, its ink and its blur. Everywhere else the field is solid.

In Five Looks

NumberInput as shipped, and with the sizes above, in each look on the theme picked in the docs. The Photo looks turn glass on over a photo.

Today
Dark
Dark + Photo
Light
Light + Photo

API Reference

NumberInputProps

PropTypeDefaultDescription
valuenumber—Controlled numeric value.
defaultValuenumber—Default value for uncontrolled usage.
onChange(value: number | undefined) => void—Callback when the value changes.
minnumber—Minimum allowed value.
maxnumber—Maximum allowed value.
stepnumber1Increment/decrement step size.
disabledbooleanfalseDisables the number input and buttons.

Accessibility

  • Always provide an aria-label or pair with a <Label> using htmlFor/id — the component has no visible label by default
  • The buttons have aria-label="Decrease value" and aria-label="Increase value", and stay out of the tab order: the keyboard steps the value instead
  • The input renders as type="text" with inputmode="numeric" for appropriate mobile keyboard
  • Keyboard: ArrowUp and ArrowDown step the value by step, holding at min and max. A caller's onKeyDown runs first and can cancel the step with preventDefault()
  • From empty, the first press of either button lands on min when one is set
  • min/max bounds are enforced both visually (buttons disable at bounds) and on input blur