Button
FREEButton with variants, sizes, start/end icons, loading state and ButtonGroup. Supports asChild.
Playground
Change the props and watch the component and its code update live.
Props
Code
import { Rocket } from "lucide-react";
import { Button } from "@/components/ui/button";
<Button
startIcon={<Rocket />}
>
Deploy
</Button>Installation
Terminal
npx @bloxa/cli add button
# or: npx shadcn@latest add @bloxa/buttonInstall separately: hold-button
Terminal
npx shadcn@latest add @bloxa/hold-buttonPackages installed automatically: radix-ui, class-variance-authority
Examples
Variants
Five visual styles; use primary for the main action.
Sizes
Icons
startIcon / endIcon, or icon only. Give icon-only buttons an aria-label.
Loading
Width stays fixed and the button is disabled. Click the first button to try it.
Button group
Split button
Main action plus a dropdown; menus can have submenus.
Hold to confirm
For risky actions. Releasing early cancels.
Press and hold for 1.2 seconds.
API reference
Every component also accepts the props of the element it renders.
Button
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "primary" | "secondary" | "outline" | "ghost" | "destructive" | "primary" | Visual style. |
| size | "sm" | "md" | "lg" | "icon" | "icon-sm" | "md" | Size; icon sizes are square. |
| startIcon | ReactNode | — | Icon before the label. |
| endIcon | ReactNode | — | Icon after the label. |
| loading | boolean | false | Shows a spinner, keeps the width and disables the button. |
| asChild | boolean | false | Applies the styles to the child element (e.g. <a>). |
ButtonGroup
Joins buttons into one segment.
HoldButton
Installed separately with @bloxa/hold-button.
| Prop | Type | Default | Description |
|---|---|---|---|
| onConfirm | () => void | — | Runs when the hold completes. |
| duration | number | 1200 | Hold duration in milliseconds. |
| variant | ButtonProps["variant"] | "destructive" | Button style. |
| size | ButtonProps["size"] | "md" | Button size. |