Skip to Content
Dashflow Logo

Button Component

A comprehensive guide to using the Button component with examples, props, and best practices.


Overview

The Button component is a versatile, accessible button element that supports multiple variants, sizes, shapes, and states. It provides a consistent design system for all interactive elements in your application.

Basic Usage

import { Button } from '@dashflowx/core'
export default function ButtonExample() {
return (
<Button variant="primary" size="md">
Click me
</Button>
)
}

Preview:

Loading Button...

Props

PropTypeDefaultDescription
variantButtonVariant'primary'Visual style variant of the button
sizeButtonSize'md'Size of the button component
shapeButtonShape'default'Shape and border radius of the button
disabledbooleanfalseWhether the button is disabled
loadingbooleanfalseShows loading spinner and disables button
fullWidthbooleanfalseMakes button take full width of container
iconReactNode-Icon to display in the button
iconPosition'left' | 'right''left'Position of the icon relative to text
type'button' | 'submit' | 'reset''button'HTML button type attribute
hrefstring-Makes button render as a link
targetstring-Target attribute for link buttons
relstring-Rel attribute for link buttons
classNamestring''Additional CSS classes

Variants

Primary

Default button with solid blue background and white text.

<Button variant="primary" size="md">
Primary Button
</Button>
Loading Button...

Secondary

Secondary button with gray background and white text.

<Button variant="secondary" size="md">
Secondary Button
</Button>
Loading Button...

Outline

Button with transparent background and bordered outline.

<Button variant="outline" size="md">
Outline Button
</Button>
Loading Button...

Ghost

Button with transparent background and no border.

<Button variant="ghost" size="md">
Ghost Button
</Button>
Loading Button...

Destructive

Button for dangerous actions with red styling.

<Button variant="destructive" size="md">
Delete
</Button>
Loading Button...

Success

Button for positive actions with green styling.

<Button variant="success" size="md">
Save Changes
</Button>
Loading Button...

Warning

Button for cautionary actions with orange styling.

<Button variant="warning" size="md">
Proceed with Caution
</Button>
Loading Button...

Info

Button for informational actions with blue styling.

<Button variant="info" size="md">
Learn More
</Button>
Loading Button...

Light

Button with light background and dark text.

<Button variant="light" size="md">
Light Button
</Button>
Loading Button...

Dark

Button with dark background and light text.

<Button variant="dark" size="md">
Dark Button
</Button>
Loading Button...

Gradient

Button with beautiful gradient background.

<Button variant="gradient" size="md">
Gradient Button
</Button>
Loading Button...

Glass

Button with glassmorphism effect.

<Button variant="glass" size="md">
Glass Button
</Button>
Loading Button...

Neon

Button with neon glow effect.

<Button variant="neon" size="md">
Neon Button
</Button>
Loading Button...

Soft

Button with soft, muted styling.

<Button variant="soft" size="md">
Soft Button
</Button>
Loading Button...

Bordered

Button with prominent border styling.

<Button variant="bordered" size="md">
Bordered Button
</Button>
Loading Button...

Sizes

Extra Small

Compact size for tight spaces.

<Button variant="primary" size="xs">
XS Button
</Button>
Loading Button...

Small

Small size for secondary actions.

<Button variant="primary" size="sm">
Small Button
</Button>
Loading Button...

Medium

Standard size for most use cases.

<Button variant="primary" size="md">
Medium Button
</Button>
Loading Button...

Large

Large size for prominent actions.

<Button variant="primary" size="lg">
Large Button
</Button>
Loading Button...

Extra Large

Extra large size for hero sections.

<Button variant="primary" size="xl">
XL Button
</Button>
Loading Button...

2XL

Massive size for maximum impact.

<Button variant="primary" size="2xl">
2XL Button
</Button>
Loading Button...

Shapes

Default

Standard rounded corners.

<Button variant="primary" size="md" shape="default">
Default Shape
</Button>
Loading Button...

Rounded

More rounded corners for a softer look.

<Button variant="primary" size="md" shape="rounded">
Rounded Shape
</Button>
Loading Button...

Pill

Fully rounded for a pill-like appearance.

<Button variant="primary" size="md" shape="pill">
Pill Shape
</Button>
Loading Button...

Square

Sharp corners for a modern look.

<Button variant="primary" size="md" shape="square">
Square Shape
</Button>
Loading Button...

Circle

Perfect circle for icon-only buttons.

<Button variant="primary" size="md" shape="circle">
</Button>
Loading Button...

States

Disabled

Button that cannot be interacted with.

<Button variant="primary" size="md" disabled>
Disabled Button
</Button>
Loading Button...

Loading

Button with loading spinner and disabled state.

<Button variant="primary" size="md" loading>
Loading...
</Button>
Loading Button...

Full Width

Button that takes the full width of its container.

<Button variant="primary" size="md" fullWidth>
Full Width Button
</Button>
Loading Button...

Button Types

Submit

Button for form submission.

<Button variant="primary" size="md" type="submit">
Submit Form
</Button>
Loading Button...

Reset

Button for form reset.

<Button variant="secondary" size="md" type="reset">
Reset Form
</Button>
Loading Button...

Button that renders as a link.

<Button variant="outline" size="md" href="/docs">
Go to Docs
</Button>
Loading Button...

Advanced Examples

Icon with Text

<Button variant="primary" size="md" icon="🚀" iconPosition="left">
Launch App
</Button>
Loading Button...

Icon Only (Circle)

<Button variant="primary" size="md" shape="circle" icon="⚙️">
</Button>
Loading Button...

Gradient with Pill Shape

<Button variant="gradient" size="lg" shape="pill">
Get Started
</Button>
Loading Button...

Glass Effect with Large Size

<Button variant="glass" size="xl" shape="rounded">
Explore Features
</Button>
Loading Button...

Neon with Custom Classes

<Button variant="neon" size="lg" className="shadow-2xl">
Neon Glow
</Button>
Loading Button...

Common Use Cases

Primary Actions

<Button variant="primary" size="lg">
Create Account
</Button>

Secondary Actions

<Button variant="secondary" size="md">
Learn More
</Button>

Form Actions

<div className="flex gap-2">
<Button variant="primary" type="submit">
Save Changes
</Button>
<Button variant="outline" type="reset">
Cancel
</Button>
</div>
<Button variant="ghost" href="/dashboard">
Go to Dashboard
</Button>

Destructive Actions

<Button variant="destructive" size="md">
Delete Account
</Button>

Best Practices

Choose the Right Variant

  • Use primary for main actions
  • Use secondary for alternative actions
  • Use outline for subtle emphasis
  • Use ghost for minimal styling
  • Use destructive for dangerous actions
  • Use success for positive actions
  • Use warning for cautionary actions
  • Use info for informational actions
  • Use light/dark for theme variations
  • Use gradient for eye-catching elements
  • Use glass for modern interfaces
  • Use neon for futuristic designs
  • Use soft for gentle interactions
  • Use bordered for structured layouts

Select Appropriate Sizes

  • Use xs for tight spaces and icons
  • Use sm for secondary actions
  • Use md for standard buttons
  • Use lg for prominent actions
  • Use xl for hero sections
  • Use 2xl for maximum impact

Pick Suitable Shapes

  • Use default for standard interfaces
  • Use rounded for softer designs
  • Use pill for modern aesthetics
  • Use square for structured layouts
  • Use circle for icon-only buttons

State Management

  • Always provide loading states for async actions
  • Disable buttons during processing
  • Use appropriate button types for forms
  • Consider full-width for mobile-first designs

Accessibility

  • Ensure sufficient color contrast for all variants
  • Provide loading states for better UX
  • Use semantic button types
  • Include proper ARIA labels for icon-only buttons
Edit this page on GitHub