Design and export custom CSS buttons with gradients, shadows, and hover effects
Preview
Preview bg
Quick presets
CSS output
CSS Button Generator is a visual designer for CSS buttons. Adjust every button property through sliders and color pickers — background, text, border, radius, padding, shadow, hover states — and see the result live. Copy the clean, dependency-free CSS output and paste it anywhere. No framework, no class library required.
.btn class — drop it into any stylesheet.Background modes
background-color.linear-gradient from two color stops with configurable angle. The hover state auto-lightens or darkens the stops.Hover effects available: color shift · scale transform · shadow lift · brightness filter. All transitions use transition: all [duration]s ease.
Every property update recomputes the button’s inline style and reflects it in the preview in real time — no debounce, changes are immediate. The shadow control combines five independent inputs (offset-x, offset-y, blur, spread, color) into a single box-shadow property. Hover styles are emitted as a separate :hover rule block.
The gradient hover effect works by computing a lightened or darkened version of each stop color: parse the hex to RGB, adjust each channel by a fixed delta, clamp to 0–255, convert back to hex. This keeps hover state visually coherent without requiring manual color picking.
CSS output format:
.btn {
background: linear-gradient(135deg, #6366f1, #8b5cf6);
color: #ffffff;
padding: 12px 24px;
border-radius: 8px;
border: none;
font-size: 16px;
font-weight: 600;
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
cursor: pointer;
transition: all 0.2s ease;
}
.btn:hover {
background: linear-gradient(135deg, #818cf8, #a78bfa);
transform: scale(1.02);
box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}
Buttons are the most common interactive element in any UI, and they’re deceptively hard to get right. The visual properties are straightforward — but the behavioral properties that make a button feel good to use require deliberate attention.
The properties that make a button feel responsive:
transform: scale(1.02) is subtle but effective. It communicates interactivity without being distracting. scale(1.05) starts to look jumpy.box-shadow blur on hover implies the button is lifting off the surface toward the user. This is a physicality metaphor that reinforces clickability.cursor: pointer feels like a broken link.Focus rings and accessibility: A button that looks good but has no visible focus ring fails WCAG 2.1 AA. Users who navigate by keyboard (and screen reader users) need to see which element is focused. The browser’s default focus ring (outline: 2px solid -webkit-focus-ring-color) is often removed by designers with outline: none and not replaced. The right fix is a custom focus ring that matches the button’s visual style: button:focus-visible { outline: 2px solid #6366f1; outline-offset: 2px; }. The :focus-visible pseudo-class applies only during keyboard navigation, not mouse clicks — no ugly rings on click, correct rings on tab.
Design systems and CSS variables: For a multi-component design system, button styles should be driven by CSS custom properties so theme changes propagate everywhere:
.btn {
background: var(--color-primary);
color: var(--color-on-primary);
border-radius: var(--radius-md);
}
This generator outputs concrete values. If you’re building a design system, use the output as a starting point, then refactor the hex values to variable references.
Tailwind v4 integration: Tailwind v4 uses CSS custom properties natively. For simple buttons, class="bg-indigo-500 hover:bg-indigo-600 text-white px-6 py-3 rounded-lg shadow transition" covers the basics. For complex gradient buttons or custom shadows, raw CSS (from this generator) in a <style> block or @layer components is cleaner than stacking Tailwind arbitrary values.
When to use a component library instead: If you need button variants (primary, secondary, ghost, destructive), loading states, icon slots, size variants, and accessibility built in — use a component library (shadcn/ui, Radix, Headless UI). This generator is for one-off custom buttons, quick prototypes, and learning what CSS properties produce which visual effects.
blur: 12px, spread: -2px at low opacity is the most tasteful option.:focus-visible. Paste the generated CSS, then add a :focus-visible rule with an outline that matches the button’s accent color. Don’t ship a button without it.For informational purposes only. Not financial, medical, or legal advice. You are solely responsible for how you use these tools.