bearnie

Number Input

A numeric input with increment and decrement steppers.

Installation

npx bearnie add number-input
npx bearnie add number-input

Usage

import { NumberInput } from "@/components/bearnie/number-input"
<NumberInput name="quantity" defaultValue={1} min={0} max={99} />

A native input[type=number] with the browser spinners hidden and proper buttons instead, so typing, arrow keys, and form submission all work as usual. The buttons respect min, max, and step, and disable themselves at the bounds.

Examples

Step

step controls the increment — arrow keys and buttons both use it.

With a label

Disabled

Props

Prop Type Default Description
name string - Form field name
id string - Id for pairing with a Label
defaultValue number - Initial value
min / max number - Bounds — the matching button disables at the edge
step number 1 Increment used by the buttons and arrow keys
disabled boolean false Disable the control
class string - Additional CSS classes

Events

Dispatches a bubbling number-change CustomEvent on every change: detail is { value } (a number, or null while the field is empty).