Skip to content

Number Input

Numeric input with stepper buttons, min/max clamping, precision, prefix/suffix slots, and locale-aware formatting via `Intl.NumberFormat`.

Forms & Inputs·Available inReactVueAngular·View as Markdown

Preview

tsx

Switch the framework picker (top-right of the panel) to render the same demo live in React, Vue, or Angular — same class names, ARIA, and visual output across all three.

Playground

Flip props to see how the component responds. The snippet below updates as you change options.

Installation

Sisyphos UI ships unified packages for React, Vue, and Angular. Pick the one that matches your stack — every framework exports the same component classes, ARIA semantics, and CSS tokens.

$ pnpm add @sisyphos-ui/react

Then import the bundled stylesheet once at app entry: import "@sisyphos-ui/react/styles.css";

Usage

Idiomatic usage in each supported framework
import { useState } from "react";
import { NumberInput } from "@sisyphos-ui/react";

export const Quantity = () => {
  const [n, setN] = useState(1);
  return <NumberInput label="Quantity" value={n} onChange={setN} min={1} step={1} />;
};

With currency prefix

`prefix` + `precision` format money-shaped values.

tsx
$

With suffix

Put units after the value with `suffix`.

tsx
kg

Error state

Track validation yourself and toggle `error` on the control.

tsx

At least 1 seat is required.

API

PropTypeDefaultDescription
valuenumber | nullControlled numeric value.
defaultValuenumber | nullInitial uncontrolled value.
onChange(next: number | null) => voidCalled with the next numeric value or `null` when the field is empty.
minnumberLower bound; values below it are clamped.
maxnumberUpper bound; values above it are clamped.
stepnumber1Step amount for stepper buttons and arrow keys.
precisionnumber0Decimal places shown when formatted.
localestringBCP 47 locale tag for `Intl.NumberFormat`. Defaults to the runtime locale; pass an explicit string for a fixed format.
numberFormatOptionsIntl.NumberFormatOptionsCustom `Intl.NumberFormat` options (overrides `precision` when set).
withStepperbooleantrueRender +/- stepper buttons.
prefixReactNodeSlot rendered before the value (e.g. `$`).
suffixReactNodeSlot rendered after the value (e.g. `TL`, `kg`).
variant"standard" | "outlined" | "underline""outlined"Visual treatment, mirrors `<Input>`.
size"sm" | "md" | "lg""md"Field height + typography scale.
labelstringField label rendered above the input.
errorbooleanfalseMarks the field as invalid for styling and ARIA.
errorMessagestringMessage shown below the field when `error` is true.
fullWidthbooleanfalseStretch the input to its container width.

The full API including refs, ARIA attributes, and HTML passthroughs lives in the package README on npm.

Accessibility

  • Stepper buttons carry descriptive aria-labels and a tabIndex={-1} so keyboard focus stays on the input.
  • aria-invalid mirrors error; the error message is announced with role="alert".

Keyboard interactions

KeyAction
ArrowUpIncrements by `step`.
ArrowDownDecrements by `step`.
PageUpthenPageDownCoarse increment / decrement (10× step).
Need more?View on npm →
Was this page helpful?