CSS Button Style Generator with Hover, Active and Focus States

Builds button CSS with separate hover, active, focus-visible and disabled states and a live preview.

Use the tool

Why this tool exists

A button needs more than a background colour: hover, pressed, keyboard focus and disabled all need to look right.

This tool writes all of those states, uses :focus-visible so keyboard users see an outline without mouse clicks adding one, and adds a reduced-motion override for the transition. Pick colours with enough contrast: the text colour against each background should reach at least 4.5 to 1.

How to use it

  1. Set colours, border, radius, padding and font.
  2. Choose hover and active backgrounds.
  3. Try the preview with mouse and keyboard.
  4. Copy the CSS.

Frequently asked questions

Why focus-visible?

It shows the outline for keyboard focus but not for mouse clicks, which is what most designers want.

Does it check contrast?

No. Use the contrast checker with your chosen colours.

Can I use it for links?

Yes, apply the class to an a element, but keep real buttons for actions.