Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Shadcn Number Input for React and Tailwind

Numeric input for entering values.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/number-input.json

Anatomy

NumberInput
├── NumberInputInput
├── NumberInputGroup
├── NumberInputValueText
├── NumberInputIncrement
├── NumberInputDecrement
└── NumberInputScrubber
    └── NumberInputLabel

Usage

import {
  NumberInput,
  NumberInputDecrement,
  NumberInputGroup,
  NumberInputIncrement,
  NumberInputInput,
} from "@/components/ui/number-input";
<NumberInput className="w-full max-w-48" defaultValue="1">
  <NumberInputGroup>
    <NumberInputDecrement />
    <NumberInputInput />
    <NumberInputIncrement />
  </NumberInputGroup>
</NumberInput>

Accessibility

KeyDescription
ArrowUp
Move up.
ArrowDown
Move down.
Home
Go to the start.
End
Go to the end.
Enter
Activate the focused item.
Space
Activate the focused control.

Demos

Controlled

Disabled

Field Only

Formatted

Invalid

Mouse Wheel

Range

Scrub

Size Lg

Size Md

Size Sm

Step

With Field

With Input Group

API Reference

NumberInput

div

PropType
AttributeType

NumberInputLabel

label

PropType

NumberInputInput

input

PropType
AttributeType

NumberInputGroup

div

PropType
AttributeType

NumberInputIncrement

button

PropType
AttributeType
CSS variableType

NumberInputDecrement

button

PropType
AttributeType
CSS variableType

NumberInputScrubber

div

PropType
AttributeType

useNumberInput