Button
A versatile and accessible button component with multiple variants, sizes, and states. Ideal for primary actions, secondary options, and loading indicators in forms and interfaces.
Install Dependencies
npx quickcode-ui add Button
Default Usage
Default Button
Variants
Outline Variant
Secondary Variant
Ghost Variant
Destructive Variant
Link Variant
Sizes and Loading
Small Size
Large Size
Loading State
Props
Prop | Type | Default | Description |
---|---|---|---|
variant | "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | "default" | Visual style of the button, affecting background, border, and text colors. |
size | "default" | "sm" | "lg" | "md" | "icon" | "default" | Controls padding, height, and overall size of the button. |
isLoading | boolean | false | Shows a loading spinner and disables the button during asynchronous actions. |
disabled | boolean | false | Disables the button and applies reduced opacity. |
className | string | undefined | Additional CSS classes for custom styling overrides. |
onClick | () => void | undefined | Optional click handler function. |
type | "button" | "submit" | "reset" | "button" | HTML button type for form submissions. |
children | React.ReactNode | undefined | Button content, such as text or icons. |
Features
- Multiple Variants: Supports default (primary blue), destructive (red), outline, secondary, ghost, and link styles for diverse use cases.
- Size Options: From compact ‘sm’ to prominent ‘lg’, including icon-only buttons.
- Loading State: Built-in spinner with Lucide React icon and automatic disabling.
- Accessibility: Semantic button element with proper disabled states and screen reader support.
- Customizable: Accepts
className
for easy overrides, just like shadcn. - Dark Mode Support: Automatic theme adaptation with semantic Tailwind classes.
- Responsive: Scales well across devices with flexible sizing.
This button is most useful in forms for submit actions, in navigation for CTAs, or in dashboards for interactive elements where quick, professional interactions are needed.
Last updated on