Number Field

A numeric input with increment and decrement buttons.

Import

import { NumberField } from '@matix/components/number-field';

Usage

Min, Max, and Step

<NumberField aria-label="Rating" defaultValue={5} min={0} max={10} step={1} />

With Field

<Field label="Quantity" description="How many would you like?">
  <NumberField defaultValue={1} min={1} max={99} />
</Field>

Disabled

<NumberField aria-label="Seats" defaultValue={3} disabled />

Custom Styles

import * as stylex from '@stylexjs/stylex';

const custom = stylex.create({
  wide: { width: '200px' },
});

<NumberField sx={custom.wide} aria-label="Answer" defaultValue={42} />;

API Reference

PropTypeDefaultDescription
defaultValuenumber—Initial value (uncontrolled)
valuenumber—Controlled value
onValueChange(value: number) => void—Called when value changes
minnumber—Minimum allowed value
maxnumber—Maximum allowed value
stepnumber1Increment / decrement step
disabledbooleanfalseDisable the field
labels{ decrement?: string; increment?: string; roleDescription?: string }—Screen-reader text, for translation
icons{ decrement?: ReactNode; increment?: ReactNode }—Replaces the built-in icons. See the Icons guide
sxStyleXStyles—StyleX style override

aria-label, aria-labelledby and aria-describedby go to the input. All other props are forwarded to the underlying Base UI NumberField.

Accessibility

  • Wraps Base UI NumberField — renders a text input with inputMode set for numbers and aria-roledescription="Number field".
  • Increment and decrement buttons have accessible labels.
  • Focus ring via :focus-visible.

Keyboard

KeyAction
Arrow UpIncrement by one step
Arrow DownDecrement by one step
HomeSet to minimum value
EndSet to maximum value
TabMove focus to / from the input (the step buttons are not in the tab order)