Slide to Confirm, animated React component
A slide-to-confirm track for payments and other deliberate actions. The knob stretches along the track in proportion to how fast you drag it and squashes back when it stops, the label shimmers and fades as you pull, and past the threshold the track floods with the success colour while a check draws itself. Also includes Slide to Pay, a payment you confirm by sliding: the track pulls in to a circle under your thumb, spins while it sends and turns into a tick.
- Pro
- Inputs & Controls
- Spring
Ticks softly as the knob passes each quarter of the track, chimes on confirm and bumps if the confirm fails. The Slide to Pay variant ticks softly as you use it, chimes on the key moments and whooshes on the bigger moves. Sound is off on this site until you switch it on.
Slide to Confirm
Slide to Pay
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| label | string | "Slide to confirm" | Text inside the track before confirming. |
| successLabel | string | "Confirmed" | Text shown once confirmed. |
| pendingLabel | string | "Confirming" | Text shown while onConfirm is pending. |
| onConfirm | () => void | Promise<unknown> | — | Runs when the knob reaches the end. Return a promise to show a pending state; reject to bounce back. |
| threshold | number | 0.9 | How far (0-1) the knob must travel before letting go confirms. |
| resetAfter | number | 2200 | Return to the start this many ms after success; 0 keeps the success state. |
| accent | string | — | Colour of the trail and the arrow. Defaults to system blue. |
| successColor | string | "#248a3d" | Track colour once confirmed. |
| size | "sm" | "md" | "lg" | "md" | Track height and default width. |
| width | number | — | Track width in px. Defaults per size (260, 300, 340). |
| autoplay | boolean | false | Slides itself across and confirms (without calling onConfirm) until someone touches it. |
| disabled | boolean | false | Dims the track and ignores input. |
| SlideToPay.payee | string | "Emily Parker" | Name of the person being paid. |
| SlideToPay.note | string | "Concert tickets" | Short note shown under the payee. |
| SlideToPay.amount | number | 240 | Amount being paid. |
| SlideToPay.currency | string | "$" | Currency symbol shown before amounts. |
| SlideToPay.from | string | "Everyday debit 4821" | Account the money leaves. |
| SlideToPay.arrives | string | "Instantly" | When the payment arrives. |
| SlideToPay.onSend | () => Promise<void> | void | — | called when the slide completes; resolve when the payment is done |
| SlideToPay.enableSound | boolean | true | Soft synthesised sounds as you use it. They also follow the site-wide sound switch. |
| SlideToPay.volume | number | 0.6 | Sound level, 0 to 1. |
| SlideToPay.autoplay | boolean | false | Plays a short demo by itself until the visitor touches it. Never runs under reduced motion. |
| SlideToPay.className | string | "" | Extra classes for the outer element. |
| 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 with your API key
Slide to Confirm is a Pro item, so the CLI has to send your API key. Do this once per project:
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
nxs_and is shown only once. - In your project root, next to
package.json, create a file named.env.localwith this line, using your own key:NEXUS_API_KEY=nxs_your_key_here
- Open
components.jsonand add this entry inside the outermost braces, next to"aliases". Leave{name}and${NEXUS_API_KEY}exactly as written; the CLI fills them in:"registries": { "@nexus-labs": { "url": "https://www.nexus-ui.com/api/registry/{name}", "headers": { "Authorization": "Bearer ${NEXUS_API_KEY}" } } }
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
How Slide to Confirm works
A slide-to-confirm track. The knob is rubbery: it stretches along the track in proportion to how fast you drag it and squashes back when it stops. A trail fills behind it, the label shimmers and fades as you pull, and on release past the threshold the track floods with the success colour while a check draws itself.
The source, the install command and the build prompt come with Pro.
Slide to Confirm questions
Does it make sound, and how do I turn it off?
Ticks softly as the knob passes each quarter of the track, chimes on confirm and bumps if the confirm fails. The Slide to Pay variant ticks softly as you use it, chimes on the key moments and whooshes on the bigger moves. 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.