BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/shadcn-htmx/number-input

Number Input

shadcn-htmx/number-input
FreeComponent

Native <input type="number"> styled like Input, with optional −/+ stepper buttons that call stepUp()/stepDown(). role=spinbutton, aria-valuenow/min/max, arrow-key stepping and value clamping all come from the platform. Ships in five flavours.

Live preview

live · rendered by the registry
Rendered by shadcn-htmx on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://shadcn-htmx.productdevbook.com/r/number-input.json

Source

registry/ui/number-input.tsxshadcn-htmx.productdevbook.com/r/number-input.json · first 6 KB
1/** @jsxImportSource hono/jsx */
2import { cn, type ClassValue } from "@/registry/lib/cn"
3
4// Number Input — shadcn-htmx, htmx v4 + Tailwind v4.
5//
6// shadcn/ui has no dedicated "number input" — it composes one from <Input
7// type="number"> + Button (see repos/shadcn-ui/apps/v4/registry/new-york-v4/ui/input.tsx
8// for the Input we mirror). We do the same, but lean entirely on the platform.
9//
10// The control IS a native <input type="number">. Per MDN that element ships:
11// - implicit role="spinbutton"
12// - aria-valuenow / aria-valuemin / aria-valuemax auto-managed from
13// value / min / max — no manual ARIA
14// - the full APG spinbutton keyboard contract built in: ArrowUp increases,
15// ArrowDown decreases, plus standard single-line text editing
16// - stepUp() / stepDown() DOM methods used by the optional +/- buttons
17// See repos/mdn/files/en-us/web/html/reference/elements/input/number/index.md:298,468
18// APG: repos/aria-practices/content/patterns/spinbutton/spinbutton-pattern.html
19//
20// Because the native input already satisfies the spinbutton pattern, the only
21// JS is a 3-line stepUp/stepDown handler for the optional buttons (public/site.js,
22// keyed on data-slot="number-input"). With `steppers={false}` it is zero-JS.
23//
24// We hide the browser's default up/down spinners (they are tiny and inconsistent
25// across engines) and supply our own larger, accessible buttons instead — the
26// APG quantity-spinbutton example takes the same approach
27// (repos/aria-practices/content/patterns/spinbutton/examples/quantity-spinbutton.html).
28
29// Shared <Input> base — kept byte-for-byte in sync with registry/ui/input.tsx
30// so a number input looks identical to every other field. We add rules to hide
31// the native spinner buttons and reserve right padding when our own steppers
32// sit inside the field.
33const inputBase =
34 "flex h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none " +
35 "selection:bg-primary selection:text-primary-foreground " +
36 "placeholder:text-muted-foreground " +
37 "disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 " +
38 "md:text-sm dark:bg-input/30 " +
39 "focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 " +
40 "aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 " +
41 "[&.htmx-request]:opacity-70 " +
42// … truncated

Facts

Registry
shadcn-htmx
Type
registry:ui
Access
Free
Files written
0
Licence
MIT
First indexed
2026-08-02
Last confirmed
today

Go to the source

Docs on shadcn-htmx shadcn-htmx.productdevbook.com productdevbook/shadcn-htmx on GitHub Raw registry item This item as JSON

More from shadcn-htmx

All 83 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Accordionaccordionshadcn-htmxComponentsFreeno deps
Active Searchactive-searchshadcn-htmxComponentsFreeno deps
Alertalertshadcn-htmxComponentsFreeno deps
Alert Dialogalert-dialogshadcn-htmxComponentsFreeno deps
Aspect Ratioaspect-ratioshadcn-htmxComponentsFreeno deps
Auto Gridauto-gridshadcn-htmxComponentsFreeno deps
Autocompleteautocompleteshadcn-htmxComponentsFreeno deps
Autosize Textareaautosize-textareashadcn-htmxComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex