Skip to content

Loading Button

A button that shows a loading spinner when clicked.

Open in
Terminal window
npx shadcn@latest add https://better-ui.ditin.in/r/loading-button.json
import { LoadingButton } from "@/components/ui/loading-button";
const onClick = async () => {
// Simulate an async operation (e.g., API call)
await new Promise((resolve) => setTimeout(resolve, 3000));
console.log("Button action completed!");
};
<LoadingButton onClick={onClick}>Click me</LoadingButton>;
  • Type: React.ReactNode
  • Description: The content to display inside the button.
  • Type: "default" | "outline" | "ghost" | "link"
  • Default: "default"
  • Description: The visual style variant of the button.
  • Type: "default" | "sm" | "lg" | "icon"
  • Default: "default"
  • Description: The size of the button.
  • Type: string
  • Description: Additional CSS classes to apply to the button.
  • Type: () => Promise<void> | void
  • Description: Function to call when the button is clicked. Can be async.
  • Type: "button" | "submit" | "reset"
  • Default: "button"
  • Description: The HTML button type attribute.