Skip to content
satin

Number input

A number with − and + and the arrow keys, kept between a min and a max.

Up to 12 per table

Installation

Terminal
npm i @uisatin/ui
Import
import { NumberInput } from '@uisatin/ui/number-input'

About 13.4 kB of JavaScript, minified and gzipped, with what it imports (React aside). The stylesheet is one file for every component.

First time with Satin? Set it up once, styles and fonts included, with the installation guide.

API Reference

The NumberInput component is a spinbutton: arrow keys step, Page Up / Down step ten times, Home / End jump to the limits; a typed value is clamped and snapped on Enter or blur.

PropTypeDefault
value
number
—
defaultValue
number
0
onValueChange
(value: number) => void
—
min
number
—
max
number
—
step
number
1
size
"sm""md""lg"
"md"
formatValue
(value: number) => string
—
label
ReactNode
—
hint
ReactNode
—
error
ReactNodeboolean
—
disabled
boolean
false
name
string
—
className
string
—
ref
Ref<HTMLInputElement>
—
...props
ComponentProps<'input'>

Other attributes go to <input>

—

Accessibility

The input has role="spinbutton" with aria-valuenow, aria-valuemin, aria-valuemax and aria-valuetext from formatValue, named by label or aria-label. The − and + buttons are named "Decrease" and "Increase", point at the input with aria-controls and are left out of the tab order, since the keys do the same.

KeyAction
↑or↓Steps up or down by step.
Page UporPage DownSteps ten times.
HomeorEndJumps to min or max, when set.
EnterClamps a typed value, snaps it to step and commits it.
EscDrops what was typed and puts the last value back.