Swipe Stack, animated React component
- Pro
- Cards
- Spring
Swipe Stack
Payments to review as a deck of cards. Drag the top card right to approve or left to flag: it tilts as you pull, a stamp fades in, and once thrown the next card rises from the deck. Also includes the Motion Kit Swipe Rows variant.
Swipe Rows
Swipes a card away on throw, then chimes for approve or latches off for flag; the inbox rows do the same for archive and delete. Sound is off on this site until you switch it on.
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| payments | SwipePayment[] | DEFAULT_PAYMENTS | Cards to review, top first: { amount, from, to, note, when, hue }. "Load more" deals the same list again. |
| onDecide | (payment: SwipePayment, approved: boolean) => void | undefined | Called after a card is thrown; approved is true for right / approve and false for left / flag. |
| autoplay | boolean | false | Throws a card every 1.7 s (mostly approvals) and reloads when empty, until someone touches it. |
| swipeDistance | number | 110 | How far, in px, a card has to be dragged before letting go throws it (30 to 220). A quick flick still throws it from less. |
| tilt | number | 18 | How far the top card tilts at the edge of a drag, in degrees (0 to 45). 0 keeps it flat. |
| spacing | number | 12 | Vertical gap, in px, between the cards waiting under the top one (0 to 32). 0 stacks them straight behind it. |
| bounce | number | 1 | How much a card that is not thrown wobbles as it snaps back (0.4 to 2.5). Higher bounces more, lower settles dead. |
| flingSpeed | number | 1 | How fast a card flies off once it is thrown (0.4 to 3). Higher is quicker. |
| SwipeRows.items | SwipeRowItem[] | DEFAULT_SWIPE_MAIL | Rows to show, each { id, from, subject, time, color }. |
| SwipeRows.title | string | "Inbox" | Heading at the top of the list. |
| SwipeRows.onArchive | (item: SwipeRowItem) => void | — | Called when the user archives a row (swipe right or the right arrow key). |
| SwipeRows.onDelete | (item: SwipeRowItem) => void | — | Called when the user deletes a row (long swipe left, the Delete button, or Delete/Backspace). |
| SwipeRows.onFlag | (item: SwipeRowItem) => void | — | Called when the user taps Flag on a half-open row. |
| SwipeRows.onUndo | (item: SwipeRowItem, action: "archive" | "delete") => void | — | Called when the user undoes the last archive or delete. |
| SwipeRows.autoplay | boolean | false | Archives and deletes rows by itself, refilling the list, until someone touches it. |
| 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
Swipe Stack 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 Swipe Stack works
Inbox rows with swipe actions. Swipe right to archive: the green grows behind the row and the icon jumps once you've gone far enough. Swipe left the row. Rows close up and an undo slips in.
The source, the install command and the build prompt come with Pro.
Swipe Stack questions
How do I install Swipe Stack?
Run `npx shadcn@latest add @nexus-labs/swipe-stack`. It adds both SwipeStack and the SwipeRows variant and installs framer-motion. It is a Pro component, so it needs a Pro plan and an API key; key setup is on the CLI docs page (/docs/cli).
What data does each card take?
Pass `payments` as `{ amount, from, to, note, when, hue }`, top card first. `amount` and `when` are display strings you format yourself, and `hue` (0 to 360) colors the two avatars. "Load more" deals the same list again.
How do I find out what the user decided?
Pass `onDecide`. It is called after a card is thrown with the payment and an `approved` boolean: true for a right swipe or the approve button, false for a left swipe or the flag button.
Can I use it without dragging?
Yes. Two buttons labelled "Approve payment" and "Flag payment" throw the top card. In SwipeRows, a focused row archives on the right arrow key and deletes on Delete or Backspace.
How do I use SwipeRows for an inbox list?
Pass `items` as `{ id, from, subject, time, color }` and an optional `title` (default "Inbox"). Handle `onArchive`, `onDelete`, `onFlag` and `onUndo`; an Undo bar appears after an archive or delete.
Does it make sound, and how do I turn it off?
Swipes a card away on throw, then chimes for approve or latches off for flag; the inbox rows do the same for archive and delete. 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.

