erictsai83

Download Button

Buttons

About

A circular download action whose outline becomes the progress ring, then settles into a download-again arrow with a check badge. The done state can persist, reset, or hand off to a custom action, and downloads can be cancelable.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Download Button to your project and fits it to your theme.

Code

How Download Button is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { FolderOpen } from "lucide-react";

import type { DownloadButtonContext } from "@/components/ui/ericts-download-button";
import { DownloadButton } from "@/components/ui/ericts-download-button";

// Demo only: nothing is fetched. Progress ticks on a timer that abort clears.
function simulateDownload({ signal, setProgress }: DownloadButtonContext) {
  return new Promise<void>((resolve) => {
    let progress = 0;
    const finish = () => {
      clearInterval(timer);
      signal.removeEventListener("abort", finish);
      resolve();
    };
    const timer = setInterval(() => {
      progress = Math.min(1, progress + 0.04 + Math.random() * 0.08);
      setProgress(progress);
      if (progress >= 1) finish();
    }, 160);
    if (signal.aborted) finish();
    else signal.addEventListener("abort", finish, { once: true });
  });
}

const variants = [
  { caption: "Stays done", props: {} },
  { caption: "Resets after 2s", props: { doneDuration: 2000 } },
  { caption: "No badge", props: { badge: false } },
  {
    caption: "Cancelable, then opens",
    props: {
      cancelable: true,
      doneLabel: "Open file",
      doneIcon: <FolderOpen strokeWidth={2} />,
      onDoneClick: () => {},
    },
  },
];

export default function Preview() {
  return (
    // Replay remounts every button, which also aborts any demo download in flight.
        <div className="flex min-h-40 w-full flex-wrap items-center justify-center gap-10 px-6">
          {variants.map(({ caption, props }) => (
            <figure key={caption} className="flex flex-col items-center gap-3">
              <DownloadButton
                onDownload={simulateDownload}
                {...props}
              />
              <figcaption className="text-xs text-muted-foreground">
                {caption}
              </figcaption>
            </figure>
          ))}
        </div>
  );
}

Dependencies

More by erictsai83

View all
  • Adaptive Drawer

    Adaptive Drawer

  • Status Button

    Status Button

  • Floating Shortcut Button

    Floating Shortcut Button

  • Filter Tags

    Filter Tags

  • Feedback Popover

    Feedback Popover

  • Expandable Toolbar

    Expandable Toolbar

  • Expandable Toggle Button

    Expandable Toggle Button

  • Arc Menu

    Arc Menu

More in Buttons

View all
  • Button

    Button

    166
  • Texture Button

    Texture Button

    121
  • Button

    Button

    21
  • Figma File Button

    Figma File Button

    39
  • Native Button

    Native Button

    12
  • Button

    Button

    88
  • HeroUI Button Group

    HeroUI Button Group

    11
  • Great UI Button

    Great UI Button

    19