Number Stepper
A number stepper component
Default
Centered product showcase
Snappy tilt
Fast number transitions with directional rotation.
Quantity
2
Use the buttons, keyboard, or drag the value.
Smooth lift
A balanced transition with a subtle raised surface.
Quantity
4
Use the buttons, keyboard, or drag the value.
Slow stretch
Longer transitions with horizontal deformation.
Quantity
6
Use the buttons, keyboard, or drag the value.
Bouncy glow
A stronger spring with a drag-state glow.
Quantity
8
Use the buttons, keyboard, or drag the value.
examples.tsx
1"use client";23import { useState } from "react";45import {6 Card,7 CardContent,8 CardDescription,9 CardHeader,10 CardTitle,11} from "@/components/ui/card";12import {13 NumberStepper,14 type NumberStepperMotionPreset,15} from "@/registry/ui/number-stepper";1617type ExampleId = "snappy" | "smooth" | "slow" | "bouncy";1819const examples: Array<{20 id: ExampleId;21 title: string;22 description: string;23 preset: NumberStepperMotionPreset;24}> = [25 {26 id: "snappy",27 title: "Snappy tilt",28 description: "Fast number transitions with directional rotation.",29 preset: "snappy",30 },31 {32 id: "smooth",33 title: "Smooth lift",34 description: "A balanced transition with a subtle raised surface.",35 preset: "smooth",36 },37 {38 id: "slow",39 title: "Slow stretch",40 description: "Longer transitions with horizontal deformation.",41 preset: "slow",42 },43 {44 id: "bouncy",45 title: "Bouncy glow",46 description: "A stronger spring with a drag-state glow.",47 preset: "bouncy",48 },49];5051export function NumberStepperExamples() {52 const [values, setValues] = useState<Record<ExampleId, number>>({53 snappy: 2,54 smooth: 4,55 slow: 6,56 bouncy: 8,57 });5859 return (60 <div className="grid gap-6 md:grid-cols-2">61 {examples.map((example) => (62 <Card key={example.id}>63 <CardHeader>64 <CardTitle className="text-base">{example.title}</CardTitle>6566 <CardDescription>{example.description}</CardDescription>67 </CardHeader>6869 <CardContent>70 <NumberStepper71 value={values[example.id]}72 onValueChange={(nextValue) => {73 setValues((current) => ({74 ...current,75 [example.id]: nextValue,76 }));77 }}78 min={0}79 max={10}80 motionPreset={example.preset}81 label="Quantity"82 description="Use the buttons, keyboard, or drag the value."83 />84 </CardContent>85 </Card>86 ))}87 </div>88 );89}
Installation & source
Install via the shadcn CLI or copy the registry files manually.
bash
npx shadcn@latest add @tt-ui/number-stepper
Props
| Name | Type | Default | Description |
|---|---|---|---|
| value | number | 0 | The value of the number stepper |
| defaultValue | number | 0 | The default value of the number stepper |
| onValueChange | function | undefined | The function to handle the value change |
| onLimitReached | function | undefined | The function to handle the limit reached |
| min | number | 0 | The minimum value of the number stepper |
| max | number | 100 | The maximum value of the number stepper |
| step | number | 1 | The step of the number stepper |
| disabled | boolean | false | Whether the number stepper is disabled |
| label | React.ReactNode | undefined | The label of the number stepper |
| description | React.ReactNode | undefined | The description of the number stepper |
| ariaLabel | string | undefined | The aria label of the number stepper |
| formatValue | function | undefined | The function to format the value |
| formatAriaValue | function | undefined | The function to format the aria value |
| drag | boolean | true | Whether the number stepper is draggable |
| dragEffect | string | undefined | The effect of the drag |
| dragPixelsPerStep | number | 18 | The number of pixels per step |
| dragRange | number | 84 | The range of the drag |
| showDragHint | boolean | true | Whether the drag hint is shown |
| motionPreset | string | undefined | The motion preset of the number stepper |
| size | string | undefined | The size of the number stepper |
| decrementLabel | string | undefined | The label of the decrement button |
| incrementLabel | string | undefined | The label of the increment button |
| id | string | undefined | The id of the number stepper |
| name | string | undefined | The name of the number stepper |
| className | string | undefined | The class name of the number stepper |
| controlClassName | string | undefined | The class name of the control |
| valueClassName | string | undefined | The class name of the value |