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
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add loading-button

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { LoadingButton } from "@/components/ui/loading-button"; <LoadingButton loading={saving} loadingText="Saving..." success={done}>Save</LoadingButton>

Source code

loading-button.tsx + 1 helper

Zero 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 />
PropTypeDescription
loadingbooleanShows the spinner state.
loadingTextstringLabel while loading.
successbooleanBriefly shows the check-mark stamp.
classNamestringOptional Tailwind or custom CSS classes merged with component styles.