Components
Button
A button component with multiple variants and loading states
Installation
- $npx litefy@latest add button
- $pnpm dlx litefy@latest add button
- $yarn dlx litefy@latest add button
- $bun --bun litefy@latest add button
Usage
Different button variants for various use cases.
"use client";
import { Button } from "@/ui";
export default function Demo() {
return (
<div className="flex flex-wrap gap-3">
<Button variant="primary">Primary</Button>
<Button variant="danger">Destructive</Button>
<Button variant="outline">Outline</Button>
<Button variant="text">Text</Button>
</div>
);
}
Loading State
Buttons with loading indicators and disabled state.
"use client";
import { useState } from "react";
import { Button } from "@/ui";
export default function Demo() {
const [loading, setLoading] = useState(false);
const handleClick = () => {
setLoading(true);
setTimeout(() => setLoading(false), 2000);
};
return (
<div className="flex flex-wrap gap-3">
<Button loadingConfig={{ loading }} onClick={handleClick}>
Click Me
</Button>
<Button
variant="danger"
loadingConfig={{ loading }}
onClick={handleClick}
>
Delete
</Button>
<Button
variant="outline"
loadingConfig={{ loading }}
onClick={handleClick}
>
Submit
</Button>
</div>
);
}
With Icons
Buttons with icon support for enhanced visual feedback.
"use client";
import { Heart, Settings, Star } from "lucide-react";
import { Button } from "@/ui";
export default function Demo() {
return (
<div className="flex flex-wrap gap-3">
<Button>
<Heart className="size-4" />
Like
</Button>
<Button variant="outline">
<Star className="size-4" />
Favorite
</Button>
<Button variant="text">
<Settings className="size-4" />
Settings
</Button>
<Button aria-label="Like">
<Heart className="size-4" />
</Button>
</div>
);
}
API Reference
Button
The button component.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'primary' | 'danger' | 'outline' | 'text' | 'primary' | Button visual variant |
className | ClassNameValue | - | Accepts strings, arrays, and all falsy values (false, null, undefined, 0, 0n). True and objects are not supported. |
loadingConfig | ButtonLoadingConfig | - | Loading state configuration |
...props | React.ComponentProps<"button"> | - | Supports all native button props (except className), such as type, disabled |
ButtonLoadingConfig
| Prop | Type | Default | Description |
|---|---|---|---|
loading | boolean | false | Whether the button is loading |
icon | React.ReactNode | - | Custom loading icon |
Button.className
Static class strings for applying the full Button look to non-button elements, such as styling an <a> link as a button. Each key is a pre-flattened, conflict-resolved full class string (base + variant), usable directly as a className without cn:
<Link to="/docs" className={Button.className.primary}>
Read the docs
</Link>| Key | Equivalent |
|---|---|
primary | variant="primary" (default) look |
danger | variant="danger" look |
outline | variant="outline" look |
text | variant="text" look |