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
| Prop | Type | Default | Description |
|---|---|---|---|
state | "idle" | "loading" | "success" | "error" | "idle" | Current button state |
variant | "primary" | "secondary" | "outline" | "primary" | Button style variant |
size | "sm" | "md" | "lg" | "md" | Button size |
className | string | - | 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

