Skip to content
synccn

Number Input

Stepper field; hold a button to repeat faster.

Team seats

$36 per month

Installation

$ pnpm dlx shadcn@latest add @synccn/number-input

First time in this project? Connect synccn with one command.

Usage

import { NumberInput } from "@/components/ui/number-input";<NumberInput min={1} max={50} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

NumberInput

Stepper input. Hold a button to repeat; arrow keys and scroll-free typing work too.

  • value
    number

    Controlled value.

  • defaultValue
    number

    Default 0

    Initial value when uncontrolled.

  • onValueChange
    (value: number) => void

    Called with the new value.

  • min
    number

    Default -Infinity

    Lowest value.

  • max
    number

    Default Infinity

    Highest value.

  • step
    number

    Default 1

    Amount per step.

  • format
    (value: number) => string

    Formats the displayed value.

  • aria-label
    string

    Accessible name for the field.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

  • lib/utilscn (merges class names)
  • lib/hooksuseControllable (works controlled or uncontrolled)

npm packages

Keyboard

  • ↑or↓Increase or decrease by one step

Accessibility

  • Holding the + or − button repeats, speeding up the longer it's held.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA attributes: aria-label
  • Keys handled: ArrowUp, ArrowDown, Enter