CSS Button Generator

Design a button with a CSS button generator and get production-ready HTML and CSS. Choose solid, gradient, outline, ghost or pill styles, set colors, font, padding, radius, border and shadow, add a hover lift, and the output already includes hover, active, keyboard focus, disabled and reduced-motion states. A live contrast check warns when the label is hard to read. It's free, runs in your browser, and nothing is uploaded.

States the CSS covers

StateSelectorWhy
Hover:hoverFeedback that it's clickable
Pressed:activeFeedback while clicking
Keyboard focus:focus-visibleRequired for keyboard users
Disabled:disabledShows it can't be used
Less motionprefers-reduced-motionRespects user settings

When to use it

  1. Make a call-to-action button that matches your brand colors.
  2. Create consistent primary, outline and ghost button styles for a design system.
  3. Get a gradient pill button with a hover lift for a landing page.
  4. Check a button's text contrast before shipping it.

How to Use

  1. Pick a preset or a style.
  2. Set the label, colors, font size, padding and radius.
  3. Toggle gradient, shadow and hover lift.
  4. Check the contrast note, then copy the HTML and CSS.

Features

  1. Solid, gradient, outline, ghost and pill
  2. Hover, active, focus-visible and disabled states
  3. Reduced-motion support
  4. WCAG contrast check
  5. Custom class name
  6. 100% client-side

FAQs

Does the CSS include hover and focus states?

Yes — hover, active, focus-visible, disabled and a reduced-motion override are all included.

Why focus-visible instead of focus?

focus-visible shows the outline for keyboard users without flashing it on every mouse click.

What contrast does a button label need?

4.5:1 for normal-size text under WCAG AA. The tool shows the ratio as you change colors.

Can I use it on a link?

Yes. Put the class on an <a> instead. Use a button element for actions and a link for navigation.

Is anything uploaded?

No. The code is generated in your browser.

Technical Details

A usable button needs more states than its resting look, so the generator writes the full set: the base style, :hover with a slightly darker fill (or a light tint for outline and ghost buttons), :active to settle any lift, :focus-visible with a high-visibility outline for keyboard users, and :disabled. Hover darkening is calculated in HSL from the chosen color so it stays in the same hue, and gradients darken both stops. A prefers-reduced-motion block removes the transition and lift for visitors who've asked for less movement. The label contrast against the background is measured with the WCAG relative-luminance formula and compared with the 4.5:1 minimum for normal text. Outline buttons take the main color for text and border; ghost buttons drop the border too. The markup is a real button element with type="button", so it doesn't accidentally submit a form. Class names are sanitized and the label is HTML-escaped before it's written.

Web & CSS Tools

Web & CSS Tools

  • CSS Text Shadow Generator
  • Glassmorphism Generator
  • Neumorphism Generator
  • CSS Filter Generator
  • CSS Loading Spinner Generator
  • CSS Toggle Switch Generator
  • CSS Checkbox Generator
  • CSS Background Pattern Generator