|$ curl https://forge-ai.dev/api/markdown?path=docs/components/buttons
$cat docs/buttons.md
updated Recently·18 min read·published

Buttons

CSSHTMLTailwindBootstrapUIIntermediate🎯Free Tools
Introduction

Buttons are the most interactive element in any UI. This guide covers production-ready button patterns in plain HTML/CSS, Tailwind CSS, and Bootstrap — including variants, sizes, states, groups, loading, and accessibility.

info

Always use <button type="button"> for non-submit actions to prevent accidental form submissions. For icon-only buttons, provide an aria-label.
Variants

Primary, secondary, outline, ghost, and danger — five variants covering every use case.

variants
Live
untitled.html
HTML
1<div class="group">
2 <button class="btn btn-primary">
3 Primary
4 </button>
5 <button class="btn btn-secondary">
6 Secondary
7 </button>
8 <button class="btn btn-outline">
9 Outline
10 </button>
11 <button class="btn btn-ghost">
12 Ghost
13 </button>
14 <button class="btn btn-danger">
15 Delete
16 </button>
17</div>
preview
Sizes

From tiny to massive — choose the right size for your layout.

sizes
Live
untitled.html
HTML
1<div class="group">
2 <button class="btn sm">
3 Small
4 </button>
5 <button class="btn md">
6 Default
7 </button>
8 <button class="btn lg">
9 Large
10 </button>
11 <button class="btn xl">
12 X-Large
13 </button>
14</div>
preview
Shapes

Rounded pills, squares, and circles for different contexts.

shapes
Live
untitled.html
HTML
1<div class="group">
2 <button class="btn primary pill">
3 Pill
4 </button>
5 <button class="btn primary square">
6 S
7 </button>
8 <button class="btn secondary circle" aria-label="Add">
9 +
10 </button>
11 <button class="btn outline pill">
12 Outline Pill
13 </button>
14</div>
preview
With Icons

Icon + label buttons and compact icon-only buttons. SVG icons scale and inherit color.

icons
Live
untitled.html
HTML
1<div class="group">
2 <button class="btn primary">
3 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="16" height="16">
4 <path d="M5 12h14M12 5l7 7-7 7"/>
5 </svg>
6 Send
7 </button>
8 <button class="btn secondary">
9 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="16" height="16">
10 <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
11 <polyline points="7 10 12 15 17 10"/>
12 <line x1="12" y1="15" x2="12" y2="3"/>
13 </svg>
14 Download
15 </button>
16 <button class="icon-btn" aria-label="Settings">
17 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
18 <circle cx="12" cy="12" r="3"/>
19 <path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/>
20 </svg>
21 </button>
22</div>
preview
Button Group

Segmented control style button groups for toggling between options.

group
Live
untitled.html
HTML
1<div class="wrapper">
2 <div class="btn-group">
3 <button class="active">
4 Day
5 </button>
6 <button>
7 Week
8 </button>
9 <button>
10 Month
11 </button>
12 </div>
13 <div class="btn-group outline">
14 <button class="active">
15 All
16 </button>
17 <button>
18 Active
19 </button>
20 <button>
21 Draft
22 </button>
23 </div>
24</div>
preview
Loading & Disabled

Spinner indicators during async operations and disabled states to prevent double-submission.

loading
Live
untitled.html
HTML
1<div class="group">
2 <button class="btn primary loading" disabled>
3 <span class="spinner">
4 </span>
5 Saving...
6 </button>
7 <button class="btn secondary" disabled>
8 Disabled
9 </button>
10</div>
preview
Social & Brand

Brand-colored social login and action buttons.

social
Live
untitled.html
HTML
1<div class="group">
2 <button class="btn github">
3 <svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16">
4 <path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z"/>
5 </svg>
6 GitHub
7 </button>
8 <button class="btn twitter">
9 <svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16">
10 <path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/>
11 </svg>
12 X
13 </button>
14 <button class="btn google">
15 <svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16">
16 <path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"/>
17 <path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"/>
18 <path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"/>
19 <path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"/>
20 </svg>
21 Google
22 </button>
23</div>
preview
Accessibility

Buttons must be keyboard focusable, have sufficient contrast, and communicate state clearly. Use aria-pressed for toggle buttons and aria-expanded for buttons that control expandable regions.

  • Use real <button> elements, not clickable divs.
  • Ensure focus styles are visible (outline or ring).
  • Icon-only buttons require an aria-label.
  • Disabled buttons should use disabled or aria-disabled.
  • Loading buttons should keep accessible text or use aria-busy.
Animations & Micro-interactions

Modern buttons feel alive with subtle motion: lift on hover, press on active, rhythmic glow for primary CTAs, and a ripple to confirm clicks. Keep durations short (150–250 ms) and easing crisp so the UI feels responsive without becoming distracting.

📝

note

Respect prefers-reduced-motion. Wrap transforms and animations in @media (prefers-reduced-motion: no-preference) or set transition-duration: 0.01ms so motion-sensitive users get an instantly static interface.
animations
Live
untitled.html
HTML
1<div class="group">
2 <button class="btn lift">
3 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="16" height="16">
4 <path d="M12 19V5M5 12l7-7 7 7"/>
5 </svg>
6 Lift
7 </button>
8 <button class="btn press">
9 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="16" height="16">
10 <path d="M12 5v14M5 12l7 7 7-7"/>
11 </svg>
12 Press
13 </button>
14 <button class="btn glow">
15 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="16" height="16">
16 <polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/>
17 </svg>
18 Glow
19 </button>
20 <button class="btn ripple">
21 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="16" height="16">
22 <circle cx="12" cy="12" r="3"/>
23 <circle cx="12" cy="12" r="8"/>
24 <circle cx="12" cy="12" r="13"/>
25 </svg>
26 Ripple
27 </button>
28</div>
preview

Community

Get help on Slack, Discord or VIP

Stuck on a guide? Join the community and ask.