Advertisement
Guide
About the CSS Button Generator
A button needs more than a colour: it has to look clickable at rest, respond on hover, react when pressed, show a clear outline for keyboard users and look unavailable when disabled. This generator writes every one of those states from a few choices.
Hover colours are derived from your brand colour automatically, and the preview is a real button — hover it, click it and Tab to it to see each state.
Focus-visible, not outline: none
Removing the focus outline makes a site unusable with a keyboard. :focus-visible shows a clear ring when someone tabs to the button, but not when they click it with a mouse, so it looks clean for everyone without hiding focus from the people who need it.
Contrast and size
Button text needs a contrast ratio of at least 4.5:1 against its background (3:1 for large text) to meet WCAG AA, and WCAG 2.2 asks for click targets of at least 24×24 pixels. The generator checks both as you design.
How to use it
- 1Pick a style and your brand colour.
- 2Set size, padding and corner radius.
- 3Choose hover and press effects.
- 4Copy the CSS and HTML, or the Tailwind classes.
Frequently asked questions
Should I use <button> or <a> for a button?
Use <button> for actions (submit, open, toggle) and <a href> for navigation to another page. The class works on both; links just need the same styles.
How do I add an icon?
Put an <svg> or icon element inside the button next to the text. The button is a flex container with a gap, so the icon lines up automatically.
How is the hover colour chosen?
Solid buttons darken the brand colour by about 12%. Outline, soft and ghost buttons add a light tint of it behind the text.
Can I make the button full width?
Add width: 100% (or Tailwind’s w-full) to the button.
Why does the Tailwind version look slightly different?
Shadows use Tailwind’s presets rather than the exact coloured shadows in the CSS. Everything else matches.
