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.
| State | Selector | Why |
|---|---|---|
| Hover | :hover | Feedback that it's clickable |
| Pressed | :active | Feedback while clicking |
| Keyboard focus | :focus-visible | Required for keyboard users |
| Disabled | :disabled | Shows it can't be used |
| Less motion | prefers-reduced-motion | Respects user settings |
Yes — hover, active, focus-visible, disabled and a reduced-motion override are all included.
focus-visible shows the outline for keyboard users without flashing it on every mouse click.
4.5:1 for normal-size text under WCAG AA. The tool shows the ratio as you change colors.
Yes. Put the class on an <a> instead. Use a button element for actions and a link for navigation.
No. The code is generated in your browser.
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.