Base Button Reset
Start with a reset that removes browser default styling, then build every variant on top of shared base styles.
CSS – Base button
/* Apply to all buttons */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 0.6rem 1.4rem;
border: none;
border-radius: 6px;
font-size: 0.95rem;
font-weight: 600;
font-family: inherit;
line-height: 1;
cursor: pointer;
text-decoration: none;
transition: all 0.2s ease;
white-space: nowrap;
user-select: none;
}
.btn:focus-visible {
outline: 2px solid #1572B6;
outline-offset: 3px;
}
.btn:disabled,
.btn[disabled] {
cursor: not-allowed;
opacity: 0.6;
pointer-events: none;
}
Primary, Secondary, Danger, Success
CSS – Solid variants
.btn-primary {
background: #1572B6;
color: #fff;
box-shadow: 0 2px 6px rgba(21, 114, 182, 0.3);
}
.btn-primary:hover {
background: #0f5fa0;
transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(21, 114, 182, 0.4);
}
.btn-primary:active { transform: translateY(0); }
.btn-secondary { background: #f0f0f0; color: #333; }
.btn-secondary:hover { background: #e0e0e0; transform: translateY(-2px); }
.btn-danger { background: #e44d26; color: #fff; }
.btn-danger:hover { background: #c63e1c; transform: translateY(-2px); }
.btn-success { background: #2e7d32; color: #fff; }
.btn-success:hover { background: #1b5e20; transform: translateY(-2px); }
Outline and Ghost
CSS – Outline and Ghost
.btn-outline {
background: transparent;
color: #1572B6;
border: 2px solid #1572B6;
}
.btn-outline:hover {
background: #1572B6;
color: #fff;
}
/* Ghost: no border visible until hover */
.btn-ghost {
background: transparent;
color: #1572B6;
border: 2px solid transparent;
}
.btn-ghost:hover {
background: rgba(21, 114, 182, 0.08);
border-color: rgba(21, 114, 182, 0.3);
}
Ad – 336×280
Pill and Gradient
CSS – Pill and Gradient
/* Pill — any button variant with full border-radius */
.btn-pill { border-radius: 9999px; }
/* Gradient */
.btn-gradient {
background: linear-gradient(135deg, #1572B6, #9c27b0);
color: #fff;
border-radius: 9999px;
}
.btn-gradient:hover {
background: linear-gradient(135deg, #0f5fa0, #7b1fa2);
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(21, 114, 182, 0.4);
}
3D and Glass
CSS – 3D and Glass
/* 3D — bottom border simulates depth */
.btn-3d {
background: #1572B6;
color: #fff;
border-bottom: 4px solid #0d4d8a;
transform: translateY(0);
}
.btn-3d:hover { transform: translateY(-2px); border-bottom-width: 6px; }
.btn-3d:active { transform: translateY(2px); border-bottom-width: 2px; }
/* Glass morphism — needs a colorful background behind it */
.btn-glass {
background: rgba(255, 255, 255, 0.15);
color: #fff;
border: 1px solid rgba(255, 255, 255, 0.3);
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
}
.btn-glass:hover { background: rgba(255, 255, 255, 0.25); }
Loading State and Icon Button
CSS – Loading and Icon
/* Loading spinner inside button */
@keyframes spin { to { transform: rotate(360deg); } }
.btn-loading {
background: #1572B6;
color: #fff;
pointer-events: none; /* prevent clicks while loading */
opacity: 0.8;
}
.btn-loading .spinner {
width: 16px;
height: 16px;
border: 2px solid rgba(255,255,255,.4);
border-top-color: #fff;
border-radius: 50%;
animation: spin 0.7s linear infinite;
}
/* Circular icon button */
.btn-icon {
width: 42px;
height: 42px;
padding: 0;
border-radius: 50%;
}
.btn-icon:hover { transform: scale(1.1); }
/* Size variants */
.btn-sm { padding: .4rem 1rem; font-size: .82rem; }
.btn-lg { padding: .9rem 2rem; font-size: 1.1rem; }
Full Token-Based Button System
CSS – Complete button system
:root {
--btn-radius: 6px;
--btn-padding: 0.6rem 1.4rem;
--btn-font: 0.95rem;
--btn-weight: 600;
--btn-ease: cubic-bezier(.4, 0, .2, 1);
--btn-duration: 200ms;
}
/* Base */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: .5rem;
padding: var(--btn-padding);
border: none;
border-radius: var(--btn-radius);
font-size: var(--btn-font);
font-weight: var(--btn-weight);
font-family: inherit;
cursor: pointer;
transition: all var(--btn-duration) var(--btn-ease);
text-decoration: none;
white-space: nowrap;
user-select: none;
}
/* Colors via custom properties on each variant */
.btn-primary { --c: #1572B6; --c-hover: #0f5fa0; background: var(--c); color: #fff; }
.btn-danger { --c: #e44d26; --c-hover: #c63e1c; background: var(--c); color: #fff; }
.btn-success { --c: #2e7d32; --c-hover: #1b5e20; background: var(--c); color: #fff; }
.btn-primary:hover,
.btn-danger:hover,
.btn-success:hover {
background: var(--c-hover);
transform: translateY(-2px);
box-shadow: 0 6px 16px color-mix(in srgb, var(--c) 50%, transparent);
}