Slide Action Button

Drag the thumb to the end to confirm, or let go early and it springs back.

Preview

"use client";

import { useState } from "react";
import { SlideActionButton } from "@/components/motion/slide-action-button";

export function SlideActionButtonPreview() {
  const [continued, setContinued] = useState(false);

  return (
    <div className="flex flex-col items-center gap-3">
      <SlideActionButton
        completeLabel="Ready"
        onComplete={() => {
          setContinued(true);
          window.setTimeout(() => setContinued(false), 1800);
        }}
      >
        Slide to continue
      </SlideActionButton>
      <p className="h-4 text-xs text-muted-foreground" aria-live="polite">
        {continued ? "Action completed" : "Drag the arrow to the end"}
      </p>
    </div>
  );
}

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/slide-action-button

API Reference

completeLabel?
ReactNode

Label shown once the slide completes. Default: "Complete"

Default—
threshold?
number

Fraction of the track (0 to 1) the thumb must pass to complete. Default: 0.82

Default0.82
resetDelay?
number

Time before the thumb slides back after completing (ms). Default: 1200

Default1200
onComplete?
(() => void)

Called when the thumb is released past the threshold, or on Enter or Space.

Default—
thumbClassName?
string

Classes merged onto the draggable thumb.

Default—
fillClassName?
string

Classes merged onto the fill that trails the thumb.

Default—
labels?
Partial<{ complete: string; thumbLabel: string; }>

Override any built-in string.

Default—
className?
string

Classes merged onto the root element.

Default—

More in Animated CTA Buttons

Updated