Button
NavigationPrimary action trigger with variants: default, destructive, outline, secondary, ghost, link. Multiple sizes available.
Responsive viewport — resize the window to explore. Direction and density apply only to this preview. Theme applies to the docs too.
"use client";
import { Button } from "@dashboardpack/core/components/ui/button";
import { Plus, LoaderCircle } from "lucide-react";
import { useState } from "react";
export default function ButtonExample() {
const [count, setCount] = useState(0);
return (
<div className="space-y-6">
<div className="flex flex-wrap gap-3">
{(
[
"default",
"secondary",
"outline",
"ghost",
"destructive",
"link",
] as const
).map((variant) => (
<Button key={variant} variant={variant}>
{variant}
</Button>
))}
</div>
<div className="flex flex-wrap items-center gap-3">
{(["xs", "sm", "default", "lg"] as const).map((size) => (
<Button key={size} size={size} variant="outline">
{size}
</Button>
))}
</div>
<div className="flex flex-wrap items-center gap-3">
{(["icon-xs", "icon-sm", "icon", "icon-lg"] as const).map((size) => (
<Button key={size} size={size} aria-label={`Add project (${size})`}>
<Plus />
</Button>
))}
</div>
<div className="flex flex-wrap gap-3">
<Button disabled>Disabled</Button>
<Button disabled>
<LoaderCircle className="animate-spin motion-reduce:animate-none" />{" "}
Saving
</Button>
<Button onClick={() => setCount(count + 1)}>
Clicked {count} times
</Button>
</div>
</div>
);
}Usage
Use a button for an action and an anchor for navigation. Use asChild to style a single link child. Add a loading icon and disable the action while a write is pending.
import { Button } from "@dashboardpack/core/components/ui/button";Available in the included @dashboardpack/core package. Copy the complete example from Source code for all imports and state. Add "use client" when using hooks or event handlers. See installation and theming for project setup.
API reference
Common props and defaults. Slot-specific props are named below; native elements also accept their standard HTML attributes. The component TypeScript definitions are the complete type reference.
| Prop | Type / Default | Description |
|---|---|---|
| variant | default | destructive | outline | secondary | ghost | linkDefault: default | Visual treatment for the action. |
| size | default | xs | sm | lg | icon | icon-xs | icon-sm | icon-lgDefault: default | Control size, including square icon buttons. |
| asChild | booleanDefault: false | Apply button styling to a single child element. |
| disabled | booleanDefault: false | Prevent interaction while unavailable. |