Command Palette

Search for a command to run...

Docs
Swipe To Confirm Button

Swipe To Confirm Button

Interactive button requiring swipe gesture for confirmation

Component swipe-to-confirm-button-demo not found in registry.

Installation

Usage

import SwipeToConfirmButton from "@/components/ruixen/swipe-to-confirm-button";
 
export default function App() {
  const handleConfirm = () => {
    console.log("Action confirmed!");
    alert("Payment processed successfully!");
  };
 
  return (
    <div className="space-y-4">
      <SwipeToConfirmButton
        label="Swipe to Pay"
        onConfirm={handleConfirm}
        width={300}
        height={60}
      />
 
      <SwipeToConfirmButton
        label="Slide to Delete"
        onConfirm={() => console.log("Deleted!")}
        width={250}
        height={50}
        className="bg-red-100"
      />
    </div>
  );
}

Props

PropTypeDefaultDescription
labelstring"Swipe to Confirm"Button label text
onConfirm() => void-Callback when swipe completes
widthnumber300Button width in pixels
heightnumber50Button height in pixels
classNamestring-Additional CSS classes

Features

  • Swipe Gesture: Drag to confirm action
  • Visual Feedback: Green background fills as you swipe
  • Snap Behavior: Snaps to end on complete swipe, resets on incomplete
  • Touch Support: Works on mobile and desktop
  • Customizable Size: Adjustable width and height
  • Elastic Constraints: Smooth drag boundaries
  • Auto Reset: Returns to start if not fully swiped

Interaction Behavior

  1. Start: Button shows label with neutral background
  2. Drag: Green background expands as you swipe right
  3. Complete: If swiped to end, triggers onConfirm and snaps
  4. Incomplete: If released early, snaps back to start

Styling

The component features:

  • Rounded Design: rounded-full for pill shape
  • Layered Background: Green fill behind white button
  • Smooth Animation: Framer Motion powered interactions
  • Theme Support: Dark mode compatible colors

Use Cases

Perfect for:

  • Payment Confirmation: "Swipe to Pay" interactions
  • Destructive Actions: "Slide to Delete" confirmations
  • Security Actions: "Swipe to Unlock" gestures
  • Critical Operations: "Slide to Confirm" for important actions
  • Mobile Interfaces: Touch-friendly confirmation patterns

Accessibility

  • Clear Labels: Descriptive text for screen readers
  • Visual Feedback: Clear indication of progress
  • Forgiving Interaction: Easy to reset if changed mind
  • Size Flexibility: Adjustable for different accessibility needs