nessra uinessra ui

Number Input

A numeric input with increment and decrement buttons.

Loading...
import { NumberInput } from "@/components/ui/number-input"

export function NumberInputDemo() {

Installation

pnpmnpmyarnbun
pnpm dlx shadcn@latest add https://nessra-ui.vercel.app/r/number-input.json

Usage

import { NumberInput } from "@/components/ui/number-input"
<NumberInput defaultValue={5} min={0} max={100} />

Examples

With Step

Use the step prop to control the increment/decrement amount.

Loading...
import { NumberInput } from "@/components/ui/number-input"

export function NumberInputStep() {

Controlled

Control the value with value and onChange.

Loading...
"use client"

import * as React from "react"

Disabled

Loading...
import { NumberInput } from "@/components/ui/number-input"

export function NumberInputDisabled() {

API Reference

NumberInput

PropTypeDefaultDescription
valuenumber-Controlled value
defaultValuenumber-Default value (uncontrolled)
onChange(value: number | undefined) => void-Called when the value changes
minnumber-Minimum allowed value
maxnumber-Maximum allowed value
stepnumber1Increment/decrement step
disabledbooleanfalseDisable the input
allowEmptybooleanfalseAllow empty value

Keyboard Navigation

KeyAction
ArrowUpIncrement value
ArrowDownDecrement value