Skip to content
StackD
Slide to pay, the StackD component

Buttons · Free

Slide to pay

Drag to pay: processing, then done.

Free on Gumroad: the download arrives in your inbox.

Details

Category
Buttons
Plan
Free
Code
React + Tailwind, TypeScript · 187 lines
Files
SlideToPay.tsx
Needs
React and Tailwind only
Agents
MCP server and shadcn registry

About

A slide-to-confirm button for checkouts. Drag the handle to the end: it locks, shows a spinner while your payment runs, then fills and ticks. Let go early and it springs back. If the payment fails it shakes and resets. Works with mouse, touch and keyboard (Enter on the handle). React + Tailwind, no other libraries.

Install

With the shadcn CLI:

npx shadcn@latest add https://www.stackd.codes/r/slide-to-pay.json

Or let your agent add it through the StackD MCP server:

claude mcp add --transport http stackd https://www.stackd.codes/mcp

Prompt for your agent

Paste it into Claude Code, Cursor, Codex or VS Code once the MCP server is connected.

Add the StackD Slide to pay component to this project. Use the StackD MCP server: call get_component with { "name": "slide-to-pay" }, write the files at the paths it gives and install any npm packages it lists. Then use it where it fits, following its README for the props, and keep its own styles.

Use

  1. Copy SlideToPay.tsx into your project (for example components/SlideToPay.tsx).
  2. Use it:
import { SlideToPay } from './components/SlideToPay'

<SlideToPay amount="€24.00" onConfirm={() => fetch('/api/pay', { method: 'POST' }).then((r) => {
  if (!r.ok) throw new Error('Payment failed')
})} />

onConfirm returns a promise. Resolve it when the payment goes through and the bar shows "Paid". Throw (or reject) and it shows "Payment failed", shakes and resets.

In Next.js the file already starts with 'use client'. In other React setups that line does nothing.

Options

PropDefaultWhat it does
amount'€24.00'Shown in the label: "Slide to pay €24.00"
onConfirma 1.6 s demoYour payment, a function that returns a promise
color'#111111'Bar colour, any CSS colour
fg'#FFFFFF'Handle and text colour, any CSS colour

Colours from StackD

White #FFFFFF · Ink #141310 · Wine #901919 · Olive #6C8544 · Ochre #BE9344 · Lilac #C9B8FF (on White and Lilac, use fg="#141310")

Licence

You can use it in personal and commercial projects. Don't resell or share the component on its own.

Made by StackD · stackd.codes

More in Buttons