Elastic Stepper, animated React component
A plus / minus stepper whose number rolls up or down, with a dot track that stretches to the current value and a rubber-band bounce when you push past either limit.
- Free
- Inputs & Controls
- Spring
Taps when you step up and ticks when you step down. Sound is off on this site until you switch it on.
Like Elastic Stepper? 301 more are in Pro.
Pro unlocks all 301 Pro components, every template and block, and everything we release next. Elastic Stepper stays free.
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| label | string | "Guests" | What is being counted; also used for the button labels. |
| min | number | 1 | Lowest value. |
| max | number | 8 | Highest value. |
| defaultValue | number | 2 | Starting value. |
| onChange | (value: number) => void | — | Called when the value changes. |
| accent | string | "#0071e3" | Dot track colour. |
| autoplay | boolean | false | Counts up and down by itself until someone interacts. |
| enableSound | boolean | true | Plays interface sounds on interaction. They follow the sound switch (setSoundsEnabled, on by default) and stay silent on hover. Autoplay makes the same sounds once the visitor has used the page. Pass false to silence this component. |
Add it to your project
- 1
Set up your project once
You need a Next.js project with Tailwind CSS and the
@/import alias. In its root folder, run this once. It createscomponents.jsonand thecn()helper insrc/lib/utils.ts:npx shadcn@latest init -d
Starting from nothing? The Quick Start walks through the whole thing.
- 2
Connect the registry
Run this once per project. It writes the Nexus UI entry into
components.jsonfor you:npx shadcn@latest registry add "@nexus-labs=https://www.nexus-ui.com/api/registry/{name}"Type it exactly as shown.
{name}is filled in by the CLI with the component you ask for, so you never replace it.
- 3
Add the component
Run this from your project root. It adds the component, the helpers it imports and its npm packages.
npx shadcn@latest add @nexus-labs/elastic-stepper
- 4
Check what was added
With a project made as in the Quick Start (a
src/folder), these files land in it:components/elastic-stepper/elastic-stepper.tsxindex.ts - 5
Copying by hand? Skip the registry
Instead of steps 2 and 3 you can copy the files yourself, with no registry and no API key. Step 1 still applies, so that
cn()exists. Install the packages:npm install framer-motion
Then show the source and create each file at the path it gives:
- 6
Use it in a page
Installing only adds the files. Import the component in a page and render it. The Usage tab on the preview shows a fuller example with props:
// src/app/page.tsx import { ElasticStepper } from "@/components/elastic-stepper"; export default function Page() { return ( <main> <ElasticStepper /> </main> ); }
Like Elastic Stepper? 301 more are in Pro.
Pro unlocks all 301 Pro components, every template and block, and everything we release next. Elastic Stepper stays free.
Elastic Stepper questions
Does it make sound, and how do I turn it off?
Taps when you step up and ticks when you step down. Sounds are synthesised with the Web Audio API, so there are no audio files, and they only play after a click or key press. Pass `enableSound={false}` to silence this component, or call `setSoundsEnabled(false)` from `@/lib/ui-sounds` to switch every sound off at once. The CLI installs `@/lib/ui-sounds` with the component.