Command Palette

Search for a command to run...

Docs
Button Loading

Button Loading

A button with loading, success, and error states for async operations.

Installation

Usage

import { useState } from "react";
import ButtonLoading from "@/components/ruixen/button-loading";
import type { LoadingButtonState } from "@/components/ruixen/button-loading";
 
export default function MyComponent() {
  const [state, setState] = useState<LoadingButtonState>("idle");
 
  const handleSubmit = async () => {
    setState("loading");
    try {
      await submitForm();
      setState("success");
    } catch {
      setState("error");
    }
  };
 
  return (
    <ButtonLoading state={state} onClick={handleSubmit}>
      Submit
    </ButtonLoading>
  );
}

Props

PropTypeDefaultDescription
state"idle" | "loading" | "success" | "error""idle"Current button state
variant"primary" | "secondary" | "outline""primary"Button style variant
size"sm" | "md" | "lg""md"Button size
classNamestring-Additional CSS classes

Features

  • Four distinct states: idle, loading, success, error
  • Animated transitions between states
  • Visual feedback with icons
  • Disabled during loading state
  • Light and dark mode support