EllyTools

Image Tools

Calculators

Text Tools

Color Tools

File Tools

Utility Tools

CSS Button Generator

Design buttons and generate CSS code

Live Preview

Hover to preview the hover effect

Generated CSS

.button {
  display: inline-block;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  background-color: #6366f1;
  border-radius: 8px;
  border: none;
  box-shadow: 0px 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.button:hover {
  background-color: #4f46e5;
  color: #ffffff;
}

.button:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

β—ˆ How to Use

1

Choose a preset or customize button styles manually

2

Adjust colors, padding, border radius, shadow, and hover effects

3

Copy the generated CSS code and use it in your project

❓ Frequently Asked Questions

Related Tools

β—‰ Who Is This For?

  • βœ“Frontend developers creating custom button styles
  • βœ“Web designers prototyping button designs quickly
  • βœ“Beginners learning CSS by experimenting with button properties

CSS buttons β€” move a slider, watch the code change

A button needs about ten lines of CSS. The difficulty is not the syntax but remembering which value at which number produces the look you had in mind. Here you push things around, look at the result, and take the code when it looks right.

What this generates is three rules: the button itself, what happens on hover, and what happens when someone arrives by keyboard. The preview and the code below it are rendered from the same list of declarations, so what you see is what gets copied.

There are two ways to change things. Pick a preset for a starting point, then adjust with the sliders. Presets apply over the defaults rather than over the current state, so nothing carries over from the preset you tried before.

What each value does

PropertyEffectA sensible range
paddingspace between text and edge12px vertical, 24px horizontal
border-radiuscorner rounding8px is normal; 50px+ gives a pill
box-shadowshadowabout 8px of blur to look slightly lifted
box-shadow (0 blur)a solid edge4px down, 0 blur reads as thickness
transitionhow long a change takes0.2s; without it changes snap
transform: scalesize on hover1.05 β€” more starts to feel jumpy

With a gradient, background-color cannot change the hover

A gradient lives in the background shorthand, and background-color is only one part of that. Set a background-color on hover while a gradient is applied and nothing happens: the gradient is still there, on top.

So when a gradient is on, this tool leaves background-color out of the hover rule entirely and changes only the scale and the text colour. To change the gradient itself on hover you have to rewrite the whole background.

People arriving by keyboard need to see the button too

Hover styling does nothing for someone tabbing through a page. To know where they are they need a focus indicator. Browsers draw one by default β€” and button styling very often removes it with outline: none.

This tool emits a :focus-visible rule alongside the rest. That selector matches keyboard navigation but not mouse clicks, so keyboard users get the indicator without a ring appearing every time anyone clicks.

The ring takes the button's background colour, falling back to the border colour for an outline button and to the text colour if there is no border β€” a transparent focus ring is the same as no focus ring.

Things to check after pasting

  • β€’The class is named .button. Rename it if your project already uses that.
  • β€’text-decoration: none is included for when the button is an <a>. Harmless on a <button>.
  • β€’A <button> element does not inherit font-family, so you may need font-family: inherit.
  • β€’Check the contrast between text and background β€” light text on a light fill is hard to read.
  • β€’A :disabled state is not generated. Add one if the button can be disabled.

Frequently asked questions

The preview and the pasted code look different.

They come from the same declaration list, so the values are identical. A difference almost always means other CSS on your page is overriding it β€” check which rule wins in developer tools.

There is no box-shadow in the code.

With both the vertical offset and the blur at zero there is nothing to draw, so the line is omitted. Raise either slider and it appears.

I use Tailwind. How does this help?

Either read the values off and translate them into utility classes, or drop the CSS into a global stylesheet as-is. Just avoid a class-name collision.

Is my button saved?

No. Everything is built in your browser and a refresh returns to the starting state.