Status Button
uselayouts/status-buttonFreeComponent
A button with animated states for idle, loading, and success.
Live preview
live · rendered by the registry
Rendered by uselayouts on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://uselayouts.com/r/status-button.jsonSource
1"use client";23import { Button } from "@/components/ui/button";4import { cn } from "@/lib/utils";5import { motion, AnimatePresence } from "motion/react";6import { Tick02Icon } from "@hugeicons/core-free-icons";7import { HugeiconsIcon } from "@hugeicons/react";8import { useMemo, useState } from "react";910export function SaveButton() {11 const [status, setStatus] = useState<"idle" | "loading" | "success">("idle");1213 const handleClick = () => {14 setStatus("loading");15 setTimeout(() => {16 setStatus("success");17 setTimeout(() => {18 setStatus("idle");19 }, 2000);20 }, 2500);21 };2223 const text = useMemo(() => {24 switch (status) {25 case "idle":26 return "Save";27 case "loading":28 return "Saving";29 case "success":30 return "Saved";31 }32 }, [status]);3334 return (35 <div className="relative inline-flex group font-sans">36 <Button37 onClick={handleClick}38 className={cn(39 "relative rounded-full h-12 px-8 text-base font-medium transition-all duration-300 min-w-[140px] disabled:opacity-100",40 status === "idle"41 ? "transition-colors"42 : "bg-muted text-muted-foreground hover:bg-muted cursor-not-allowed border-muted shadow-sm"43 )}44 variant={"default"}45 disabled={status !== "idle"}46 >47 <span className="flex items-center justify-center">48 <AnimatePresence mode="popLayout" initial={false}>49 {text.split("").map((char, i) => (50 <motion.span51 key={`${char}-${i}`}52 layout53 initial={{ opacity: 0, scale: 0, filter: "blur(4px)" }}54 animate={{ opacity: 1, scale: 1, filter: "blur(0px)" }}55 exit={{ opacity: 0, scale: 0, filter: "blur(4px)" }}56 transition={{57 type: "spring",58 stiffness: 500,59 damping: 30,60 mass: 1,61 }}62 className="inline-block"63 >64 {char}65 </motion.span>66 ))}67 </AnimatePresence>68 </span>69 </Button>7071 {/* Status Indicator */}72 <div className={cn("absolute -top-1 -right-1 z-10 pointer-events-none")}>73 <AnimatePresence mode="wait">74 {status !== "idle" && (75 <motion.div76 initial={{ opacity: 0, scale: 0, x: -8, filter: "blur(4px)" }}77// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from uselayouts
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| 3D Book3d-book | uselayouts | Components | Free | 3 deps | |
| Animated Collectionanimated-collection | uselayouts | Components | Free | 5 deps | |
| Bento Cardbento-card | uselayouts | Components | Free | 5 deps | |
| Bottom Menubottom-menu | uselayouts | Components | Free | 6 deps | |
| Bucketbucket | uselayouts | Components | Free | 5 deps · 2 files | |
| Day Pickerday-picker | uselayouts | Components | Free | 5 deps | |
| Delete Buttondelete-button | uselayouts | Components | Free | 5 deps | |
| Discover Buttondiscover-button | uselayouts | Components | Free | 5 deps |
