Docelora
ToolsAboutContact
Design tools

CSS Button Generator

Create a consistent, accessible button style for your site and copy the CSS – including hover, active, focus and disabled states.

Quick answer: pick colours and sizes; the preview updates instantly on light and dark backgrounds. Copy the CSS and use the class on button or link elements.

CSS Button Generator

Live preview · contrast check

Private: everything is generated in your browser. Nothing is uploaded.

WCAG contrast minimums

TextAAAAA
Normal text4.5:17:1
Large text (24 px, or 18.66 px bold)3:14.5:1

Related tools

Frequently asked questions

Does the CSS include hover and focus styles?

Yes – hover, active, focus-visible and disabled states are included, plus a reduced-motion rule that turns off transitions for people who prefer less movement.

What is the contrast check?

It measures the contrast ratio between the text and the button colour, using the WCAG formula, and says whether it meets the AA minimum: 4.5:1 for normal text, 3:1 for large or bold text.

Should I style a button or a link?

Use a button element for actions on the page and a link (a element) for navigation to another page. The same class styles both.

Why is there a visible focus ring?

Keyboard users need to see which button is focused. focus-visible shows the ring for keyboard focus but not for mouse clicks.

How do I add an icon?

Put an SVG inside the button – the CSS uses inline-flex with a gap, so the icon and text line up.

What is a ghost button?

A button with no background or border, only coloured text – for secondary actions.

Can I use the gradient with outline style?

No – outline and ghost buttons use the main colour for the text and border, and the gradient applies only to solid buttons.

Why does the hover darken use filter for gradients?

Gradients cannot be transitioned smoothly, so brightness() darkens them in a way that still animates.

How big should a button be on mobile?

At least about 44×44 px of tappable area is a common guideline – increase the padding if your buttons are smaller.

Can I change the font?

Yes – the CSS uses the system font stack; replace it with your site’s font.

Is it free?

Yes – no sign-up and no attribution needed.

Can I use the result commercially?

Yes. What you create is yours to use in any project.

Is anything uploaded?

No. Everything is generated in your browser; any image you choose stays on your device.

Does it work on a phone?

Yes – the controls stack on small screens and the preview updates as you change them.

Which browsers support the CSS?

The output uses standard CSS supported by all current browsers; notes on the page mention any exceptions.

How do I copy the code?

Use the Copy button under the code, or Download to save it.

Can I suggest a feature?

Yes – use the Contact page.

Do I need to credit Docelora?

No credit is needed.

Do I need design software?

No – everything works in your web browser.

Will the result look the same everywhere?

Standard CSS and PNG images display consistently across modern browsers and devices.

Last reviewed: 16 November 2026.