Skip to content

Design system

Documentation

DesignComponents / InputNumber

Components / InputNumber

Beta

InputNumber

Enter a finite numeric value with the browser's native number control and shared PhucTech input styling.

On this page

Examples

Whole number

Use the browser's native spinbutton with an explicit range and an accessible name.

Whole number input

Decimal step

The native step controls precision; the public value stays a JavaScript number.

Decimal number input

Invalid, read-only, and disabled

Use native constraints and field validation to explain values that cannot be changed.

Invalid, read-only, and disabled numeric inputs

Try the props

Change the native step and disabled state while keeping the current numeric value in feature state.

Current value: 12

InputNumber property playground

When to use

Use InputNumber for a value whose application contract is a JavaScript number, such as a count, quantity, or amount. Use Input when the entered characters themselves are the value, such as an identifier that may contain leading zeroes.

Usage

import { InputNumber } from "@phuctech/ui/components/input-number";

<InputNumber aria-label="Seats" min={1} max={100} step={1} defaultValue={5} />

For controlled use, pass value and update it from onValueChange. The callback receives a finite number or null when the input is cleared. Business rules and any display formatting stay in the feature.

API

Component API
PropTypeDefaultDescriptionConstraints
value / defaultValuenumber | null—Controlled or initial numeric value.Only finite numbers are displayed; null represents an empty input. Omit value to use uncontrolled state.
onValueChange(value: number | null) => void—Receives the parsed native input value whenever it changes.An empty input returns null; non-finite input returns null.
onChangeReact.ChangeEventHandler<HTMLInputElement>—Optional native change event handler, called after onValueChange.The underlying input remains type=number.
min / max / stepnumber | stringbrowser defaultsNative number input constraints and increment interval.These browser constraints do not replace feature-level validation.
Input propsInputProps without type/value/defaultValue/onChangeInput defaultsForwards size, name, disabled, readOnly, required, ref, className, and aria attributes.Use a visible Field label or an accessible name.

Tokens

Component tokens
TokenRoleEffective valueUsage
input / border / focus-ringNumeric controlShared Input stylingKeeps numeric entry consistent with text fields in light and dark themes.
--size-control-sm / md / lgControl heightShared control scaleInputNumber forwards the Input size variants.

Accessibility

InputNumber renders the native spinbutton semantics and preserves browser keyboard behavior. Provide a visible FieldLabel or an accessible name. Native min, max, step, disabled, readOnly, required, and aria-invalid are forwarded to the input.

Do and don’t

Do

Choose a step that matches the precision the feature accepts, and validate the final value in the feature.

Don’t

Use a number input for values where leading zeroes, separators, or exact decimal strings are meaningful.

  • Input accepts text and other native input types.
  • Field connects labels, descriptions, and validation feedback to the control.
  • Slider supports bounded numeric selection when direct typing is not the main task.