CSS Button Generator
Design a CSS button with eight presets, text, colors, font, padding, border, radius, shadow and gradient. Copy or download CSS or HTML + CSS.
Text fields accept HEX, CSS named colors and opaque rgb(). HEX/RGB contrast is calculated; named colors retain styling/export without a numeric contrast estimate. Pickers produce HEX; transparent fill assumes white. Gradient contrast compares endpoints only. Estimated height is 2×vertical padding + 2×border + 1.2×font size, rounded for display, matching the emitted line-height.
Preview
Accessibility check
Text thresholds only; this does not certify a control or page.
Customize
Quick Templates
Generated Code
Method and limits
Text fields accept HEX, CSS named colors and opaque rgb(). HEX/RGB contrast is calculated; named colors retain styling/export without a numeric contrast estimate. Pickers produce HEX; transparent fill assumes white. Gradient contrast compares endpoints only. Estimated height is 2×vertical padding + 2×border + 1.2×font size, rounded for display, matching the emitted line-height.
Height alone does not establish target size or conformance. WCAG 2.2 AA targets are 24×24 CSS px with exceptions; AAA enhanced targets are 44×44 with exceptions. Check actual width, spacing, states, background and keyboard behavior.
The source generates snippets from current settings without an upload call or saved button history. Copy and download depend on browser APIs. Ads and other site code are outside this source assessment.
Copied
Copy failed. Select the result and copy it manually.
Popular Tools
About CSS Button Generator
Design a CSS button with eight presets, text, colors, font, padding, border, radius, shadow and gradient. Copy or download CSS or HTML + CSS.
Black fill, white text, font 16px, vertical padding 12px and border 0 give 21.00:1 and an estimated 43px height (43.2 rounded). This is not a native measurement.
Text thresholds only; this does not certify a control or page.
Use Cases
How to use
Choose one of eight presets or set text and HEX, named or RGB colors manually.
Adjust font size/weight, horizontal/vertical padding, radius and border.
Choose shadow and optional gradient; read the qualified estimates.
Enable focus-visible and disabled CSS states; inspect CSS or HTML + CSS.
Copy valid code or download button.css/button.html, then test it in its actual page.
Pro Tips
- Height alone does not establish target size or conformance. WCAG 2.2 AA targets are 24×24 CSS px with exceptions; AAA enhanced targets are 44×44 with exceptions. Check actual width, spacing, states, background and keyboard behavior.
- The source generates snippets from current settings without an upload call or saved button history. Copy and download depend on browser APIs. Ads and other site code are outside this source assessment.
- Set the font size before anything else. Padding and border radius are much easier to judge once the label is at its final size, and the height readout (2 x vertical padding + 2 x border-width + 1.2 x font-size) moves with it.
- Load a preset, then tweak. Outline and Ghost already start with a border width above zero, which is the fastest route to a secondary button.
Troubleshooting
The copied CSS has no visible effect on my page.
The class is being overridden, or was never applied. Confirm the element carries class="btn", load your stylesheet after any framework CSS, and open the Styles panel in DevTools: a struck-through declaration means another selector wins on specificity or order.
The gradient looks flat or does not appear at all.
A gradient is a background image, not a background colour. Tick Gradient so the tool emits background: linear-gradient(...) instead of background-color. If it still does not show, look for a later background shorthand or a later background-image on the same element: the shorthand resets background-image to none and wipes the gradient out. A later background-color cannot hide it, because CSS Backgrounds 3 paints the colour underneath the background images.
The contrast badge says the colours fail, but the button looks fine to me.
Contrast is measured on relative luminance, not on how vivid a colour feels. Mid-tone pairs such as #f59e0b with white text land near 2:1 despite looking bright. Darken the background or switch the label to near-black; the ratio updates as you type.
Invalid or incomplete settings. Use HEX, CSS named colors or opaque rgb() (or transparent for the background), and values within the displayed ranges.
Text fields accept HEX, CSS named colors and opaque rgb(). HEX/RGB contrast is calculated; named colors retain styling/export without a numeric contrast estimate. Pickers produce HEX; transparent fill assumes white. Gradient contrast compares endpoints only. Estimated height is 2×vertical padding + 2×border + 1.2×font size, rounded for display, matching the emitted line-height.
Clipboard unavailable
Copy failed. Select the output and copy manually.
Frequently Asked Questions
Yes. HTML + CSS includes the stylesheet and a type="button" element. The toggle includes or omits focus-visible and disabled selectors in both formats. Set the disabled attribute when the application needs it.
It rounds a 43.2px formula without measuring width or the rendered target. AA 24×24 and AAA 44×44 have exceptions; evaluate the actual control and all applicable criteria.
Write one rule for the class and set six declarations: background-color, color, font-size, font-weight, padding and border-radius. Add box-shadow and a border only where the design calls for them. The generator writes exactly that rule for you: drag the sliders, watch the live preview, then copy the .btn block from the CSS tab into your stylesheet.
Use a button when the click acts on the current page: submitting a form, opening a dialog, running JavaScript. It is focusable by default, fires on Enter and Space, and supports the disabled attribute. Use an anchor with href when the click navigates to another URL, so middle-click and "open in new tab" still work. Both can carry the same .btn class.
The generated CSS already carries .btn:hover and .btn:active. Leave the focus and disabled option ticked and you also get .btn:focus-visible with a 3px outline offset by 2px, and .btn:disabled at half opacity with cursor: not-allowed. Never delete a focus outline without replacing it with something visible, or keyboard users lose all trace of where they are.
Inherited styles are almost always the cause. A framework reset, a parent font-family, a global button rule or a higher-specificity selector can override the pasted class. Load your stylesheet after the framework CSS, keep .btn on a single element, and read the Styles panel in DevTools: a struck-through declaration tells you exactly which selector won.
Use border-radius for rounded corners. A pill approaches half the actual shorter side; check the rendered box.
Text fields accept HEX, CSS named colors and opaque rgb(). HEX/RGB contrast is calculated; named colors retain styling/export without a numeric contrast estimate. Pickers produce HEX; transparent fill assumes white. Gradient contrast compares endpoints only. Estimated height is 2×vertical padding + 2×border + 1.2×font size, rounded for display, matching the emitted line-height.
The source generates snippets from current settings without an upload call or saved button history. Copy and download depend on browser APIs. Ads and other site code are outside this source assessment.