Last updated
CSS Button Generator Examples
The CSS Button Generator creates complete, production-ready button styles with all interactive states. Below are examples of common button configurations and the CSS they produce.
Primary Button — Solid Fill
A standard primary action button with hover and active states:
.btn-primary {
background-color: #3b82f6;
color: #ffffff;
border: none;
border-radius: 6px;
padding: 10px 20px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: background-color 0.2s ease, box-shadow 0.2s ease;
}
.btn-primary:hover {
background-color: #2563eb;
box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}
.btn-primary:active {
background-color: #1d4ed8;
box-shadow: none;
transform: translateY(1px);
}
.btn-primary:focus {
outline: 3px solid #93c5fd;
outline-offset: 2px;
}
.btn-primary:disabled {
opacity: 0.5;
cursor: not-allowed;
}
Outline / Ghost Button
A bordered button with transparent background, useful for secondary actions:
.btn-outline {
background-color: transparent;
color: #3b82f6;
border: 2px solid #3b82f6;
border-radius: 6px;
padding: 8px 18px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: background-color 0.2s ease, color 0.2s ease;
}
.btn-outline:hover {
background-color: #3b82f6;
color: #ffffff;
}
.btn-outline:active {
background-color: #2563eb;
border-color: #2563eb;
color: #ffffff;
}
Pill-Shaped Button
Fully rounded button using a large border-radius:
.btn-pill {
background-color: #10b981;
color: #ffffff;
border: none;
border-radius: 9999px;
padding: 10px 28px;
font-size: 15px;
font-weight: 600;
letter-spacing: 0.05em;
text-transform: uppercase;
cursor: pointer;
transition: background-color 0.2s ease, transform 0.1s ease;
}
.btn-pill:hover {
background-color: #059669;
transform: scale(1.03);
}
.btn-pill:active {
transform: scale(0.98);
}
Gradient Button
Button with a gradient background and shadow glow effect:
.btn-gradient {
background: linear-gradient(135deg, #6366f1, #8b5cf6);
color: #ffffff;
border: none;
border-radius: 8px;
padding: 12px 24px;
font-size: 16px;
font-weight: 700;
cursor: pointer;
box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
transition: box-shadow 0.2s ease, transform 0.1s ease;
}
.btn-gradient:hover {
box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
transform: translateY(-1px);
}
.btn-gradient:active {
transform: translateY(1px);
box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
Button Size Variants
Small, medium, and large sizes from a single base style:
.btn { border-radius: 6px; font-weight: 600; cursor: pointer; border: none; background-color: #3b82f6; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-md { padding: 10px 20px; font-size: 15px; }
.btn-lg { padding: 14px 28px; font-size: 18px; }
Icon Button (Square)
Equal padding on all sides for a circular or square icon button:
.btn-icon {
background-color: #f3f4f6;
color: #374151;
border: 1px solid #d1d5db;
border-radius: 8px;
padding: 10px;
width: 40px;
height: 40px;
display: inline-flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: background-color 0.2s ease;
}
.btn-icon:hover {
background-color: #e5e7eb;
}
Danger / Destructive Button
.btn-danger {
background-color: #ef4444;
color: #ffffff;
border: none;
border-radius: 6px;
padding: 10px 20px;
font-size: 15px;
font-weight: 600;
cursor: pointer;
transition: background-color 0.2s ease;
}
.btn-danger:hover { background-color: #dc2626; }
.btn-danger:active { background-color: #b91c1c; }
Common Use Cases
- Primary CTA buttons for forms and landing pages
- Secondary outline buttons for cancel or back actions
- Pill buttons for tags, filters, and toggles
- Gradient buttons for hero sections and promotional banners
- Icon buttons for toolbars and compact UIs
- Danger buttons for delete and destructive actions
- Disabled states for form validation feedback
Copy any generated CSS directly into your project. All examples include hover, active, focus, and disabled states for full accessibility and interactivity coverage.