Componentform0.74 KB gzipZero dependencies
Loading Button
Button with loading spinner swap, width locking to avoid jumps, and a brief success check-mark stamp.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add loading-buttonOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { LoadingButton } from "@/components/ui/loading-button"; <LoadingButton loading={saving} loadingText="Saving..." success={done}>Save</LoadingButton>Source code
loading-button.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxloading-button.tsx100 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export type LoadingButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & { loading?: boolean; loadingText?: string; success?: boolean; className?: string;}; const LoadingButton = React.forwardRef<HTMLButtonElement, LoadingButtonProps>( ({ loading = false, loadingText = "Loading...", success = false, className, children }, ref) => { const [isLoading, setIsLoading] = React.useState(false); const [showSuccess, setShowSuccess] = React.useState(false); React.useEffect(() => {Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { LoadingButton } from "@/components/ui/loading-button"; <LoadingButton />| Prop | Type | Description |
|---|---|---|
| loading | boolean | Shows the spinner state. |
| loadingText | string | Label while loading. |
| success | boolean | Briefly shows the check-mark stamp. |
| className | string | Optional Tailwind or custom CSS classes merged with component styles. |