CSS Button Generator
Design a CSS button with padding, font, colors, border, radius, shadow and transition. Get :hover, :active and :focus-visible CSS, HTML and a contrast check.
A good button needs more than a background color: a hover state, a pressed state, a visible keyboard focus ring, readable text and a smooth transition. This generator writes all of it from a few settings — padding, font, colors, border, radius and shadow — and computes the hover and pressed colors by darkening the background in OKLCH, which keeps the hue steady. It checks the text contrast against WCAG and renders the normal, hover, active and focus states side by side in your own browser.
How to use this tool
- Type the button text and set padding, font size and weight.
- Choose the background, text and border colors and the corner radius.
- Keep the automatic hover color or pick your own, and set the focus ring and transition.
- Copy the CSS and HTML; check the contrast line before you ship.
Formula
hover = OKLCH(L − 0.08, C, H) · active = OKLCH(L − 0.12, C, H) · contrast = (L₁ + 0.05) ÷ (L₂ + 0.05)
OKLCH lightness runs from 0 to 1, so 0.08 is 8 points. If the darker color falls outside sRGB, its chroma is reduced with the CSS Color 4 gamut-mapping method. The contrast uses WCAG relative luminance and is truncated, not rounded.
Example
The default blue #2563EB has OKLCH lightness 0.546; 8 points darker gives the hover color #0B48CF and 12 points the pressed color #003BC1. White text on #2563EB reaches 5.16:1, which passes WCAG AA for normal text (4.5:1) but not AAA (7:1).
Frequently asked questions
Why :focus-visible instead of :focus?
:focus-visible shows the outline when someone navigates with the keyboard but not after a mouse click, so the ring helps keyboard users without bothering pointer users. Never remove the focus outline without replacing it.
Why darken in OKLCH rather than HSL?
HSL lightness is not perceptual: darkening yellow and blue by the same HSL amount looks very different. OKLCH lightness steps look even across hues, so hover states feel consistent.
Should I add prefers-reduced-motion?
Yes. The generated CSS turns the transition off for people who ask their system to reduce motion — a small change that respects an accessibility setting.
Sources
Last updated:
Page address with these inputs: https://kakao.mobile/tools/css-button-generator/
Cite or embed this tool
kakaoCalc. (2026, November 8). CSS Button Generator. https://kakao.mobile/tools/css-button-generator/
“CSS Button Generator.” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/css-button-generator/.
Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms