Black Friday is here 🔥 Get Wensity Pro for 20% less with

Number Input

React number input on Base UI with carved plus and minus buttons, press and hold, arrow and scroll stepping, rolling digits and a cart quantity mode.

Loading preview

Overview

Number Input is a React and Tailwind CSS number input built on Base UI NumberField, in Next.js or any React app. Holding plus or minus repeats the step, arrow keys step too, Shift and Alt switch to largeStep and smallStep, and the mouse wheel only steps while the field is focused and hovered. Values format through Intl.NumberFormat for currency, percent or units. Each digit rolls the way the value moved and holds still under reduced motion. In the cart variant, minus turns into remove at the minimum. Clearing the field reports null, so fall back to your minimum in onValueChange.

Installation

Run the following command

~/your-project
pnpm dlx wensity@latest add number-input

Usage

Import NumberInput from @/components/wensity/number-input and render it anywhere in your React or Next.js app. The source lands in your own repo, so every prop, class and animation below is yours to edit.

app/example.tsx
"use client";
import * as React from "react";
import { NumberInput } from "@/components/wensity/number-input";
export function QuantityDemo() {
const [quantity, setQuantity] = React.useState(1);
return (
<NumberInput
label="Quantity"
value={quantity}
onValueChange={(value) => setQuantity(value ?? 1)}
min={1}
max={20}
/>
);
}

Props

PropTypeDefaultDescription
valuenumber | null-Controlled value. null leaves the field empty.
defaultValuenumber-Starting value when uncontrolled.
onValueChange(value: number | null, reason: string) => void-Called on every change with what caused it: typing, a button, a key or the wheel.
onValueCommitted(value: number | null) => void-Called on blur after typing, or when a button press or hold is released.
minnumber-Lowest value. Defaults to 1 in the cart variant.
maxnumber-Highest value.
stepnumber1Amount each press, arrow key or wheel notch moves the value.
largeStepnumber-Step while Shift is held.
smallStepnumber-Step while Alt is held.
formatIntl.NumberFormatOptions-Display format, such as currency, percent or units.
localeIntl.LocalesArgument-Locale used for formatting and parsing.
variant"default" | "cart""default"cart turns minus into a remove button at the minimum.
onRemove() => void-Called when the cart remove button is pressed.
layout"split" | "trailing""split"Buttons either side of the value, or both on the right.
size"sm" | "md" | "lg""md"Control height and text size.
rollingbooleantrueRolls each digit up or down as the value changes.
wheelStepbooleantrueSteps with the mouse wheel while the field is focused and hovered.
labelReact.ReactNode-Label above the field, wired to the input.
hintReact.ReactNode-Helper text under the field. Hidden while error is set.
errorReact.ReactNode-Error message under the field, with invalid styling.
fullWidthbooleanfalseStretches the field to fill its container.
disabledboolean-Blocks every interaction.
  • Count Up Animation component preview

    Count Up Animation

    A count up animation for React: every digit rolls into place, in any number format.

  • Text Char Slide component preview

    Text Char Slide

    A per-character slide-left cascade with a cleanly staggered entrance timing.

  • Gooey Range Slider component preview

    Gooey Range Slider

    Drag the thumb and the filled track stretches with it, then the thumb contracts into a circle when you let go.

  • Star Rating component preview

    Star Rating

    React star rating with half stars, drag to rate, and cut stars that catch the light.