A button component with 7 variants (default, outline, secondary, destructive, destructive-outline, ghost, link), 10 sizes (xs–xl + icon sizes), loading state with built-in spinner, and render-as-child support via asChild prop.
"use client"; import { Button } from "@/components/ui/component"; import { useState } from "react"; export default function ButtonLoadingDemo() { const [loading, setLoading] = useState(false); return ( <div className="flex min-h-screen w-full items-center justify-center bg-background p-8"> <div className="flex flex-wrap items-center gap-3"> <Button loading>Loading</Button> <Button loading={loading} onClick={() => { setLoading(true); setTimeout(() => setLoading(false), 2000); }} > {loading ? "Saving..." : "Click to Load"} </Button> </div> </div> ); }
Part of coss — browse the full library on 21st.dev.