Skip to content
Stylhero 0.8.0
Components

Core

Layout and type

Inputs

Overlays

Navigation

Data display

Charts

Transitions and utilities

Page pieces (landing pages, portfolios, docs)

Icons

Components / Inputs

NumberInput

Number field with − and + buttons (MUI Base's NumberInput). Arrow keys step; typing is clamped on blur.

import { NumberInput } from "@stylhero/ui";

Example

Code
import { NumberInput } from "@stylhero/ui";

function NumberInputExample() {
  return <NumberInput label="Quantity" defaultValue={1} min={1} max={10} />;
}

Props

PropTypeDefaultDescription
className string -
defaultValue number 0
disabled boolean -
error ReactNode -
hint ReactNode - Help text under the field. Replaced by error when set.
id string -
label ReactNode -
max number Infinity
min number -Infinity
name string -
onBlur (e: FocusEvent<HTMLInputElement>) => void - Runs when the text box loses focus, after a typed value is committed (react-hook-form's field.onBlur).
onValueChange (value: number) => void -
step number 1
value number -

Takes a ref.

Keyboard

KeyDoes
ArrowUp / ArrowDownAdd / subtract step
EnterCommits what you typed (also on blur)

Accessibility

  • The text box has role="spinbutton" with aria-valuenow, -min and -max. The + and − buttons ("Increase", "Decrease") are for pointer users and stay out of the Tab order: the arrow keys do the same.

Generated from src/components/NumberInput.tsx. Something wrong or missing? Open an issue.