gekro
GitHub LinkedIn
Dev · Free Tool

CSS Button Generator

Design and export custom CSS buttons with gradients, shadows, and hover effects

Background
#6366f1
Text
#ffffff
Padding
12px
24px
Border radius?
8px
Border
0
#ffffff
Box shadow?
0px
4px
12px
0px
25%
Hover effects
200ms

Preview

Preview bg

Quick presets

CSS output

© 2026 Rohit Burani · MIT · Built at gekro.com · View source ↗

Guide

What It Does

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.

How to Use It

  1. Set the background mode: Solid (single color) or Gradient (two color stops with angle control).
  2. Adjust text color, font size, and font weight.
  3. Set the border: width, color, and radius.
  4. Configure padding (vertical and horizontal independently).
  5. Build the shadow: offset-x, offset-y, blur, spread, and color.
  6. Choose hover effects: color shift, scale transform, shadow lift, or brightness filter.
  7. Copy the CSS. It targets a .btn class — drop it into any stylesheet.

Background modes

  • Solid — a single background-color.
  • Gradient — a 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.

The Math / How It Works

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);
}

Why Developers Need This (deep dive)

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:

  • Hover transition duration — 150–200ms is the sweet spot. Below 100ms, the transition is invisible. Above 300ms, the button feels sluggish.
  • Scale transform on hovertransform: scale(1.02) is subtle but effective. It communicates interactivity without being distracting. scale(1.05) starts to look jumpy.
  • Shadow lift — increasing 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 — obvious but frequently forgotten. A button without 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.

Tips & Power Use

  • Use the Color Toolkit to extract brand colors from your logo, then use those HEX values as button backgrounds. Keeps your button palette grounded in your actual brand identity.
  • Test hover states before copying. Hover over the preview button to see the hover effect in action before committing to the values.
  • Gradient angle 135° is the most versatile — it reads as “top-left to bottom-right” which aligns with how most UIs layer light. 90° (top to bottom) and 45° (diagonal) are also common.
  • Shadow blur > shadow spread produces soft, realistic shadows. Equal blur and spread produces a hard outline. For modern flat-ish UIs, blur: 12px, spread: -2px at low opacity is the most tasteful option.
  • Copy and adapt for :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.

Limitations

  • Pseudo-element decorations (animated borders, gradient underlines) are not supported — the generator targets simple, widely-compatible button patterns.
  • Tailwind output is approximate — complex shadows and custom gradients may not map to a single Tailwind utility class; use arbitrary values or raw CSS.
  • The preview uses the browser’s default system font stack unless a code font is installed that overrides the monospace default.
  • No stateful variants — loading spinner, disabled state, and active/pressed state styling are not generated. Add those manually.

For informational purposes only. Not financial, medical, or legal advice. You are solely responsible for how you use these tools.