CSS Button Generator

Enter your brand colour and get a complete button: six styles, a hover effect, a press effect and a visible keyboard focus ring. The text colour is chosen automatically for contrast. Set the corners, padding, font size and weight, try the preview with your mouse and keyboard, and copy the CSS and HTML, or one Tailwind button.

Preview background

Hover, click and Tab to the button to see every state.

Style
Hover effect

Text colour is picked for contrast automatically

Keep the button at least 44 px tall on phones so it is easy to tap: about 12 px top and bottom padding at 15 px text.

Code
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  background: #2563EB;
  color: #FFFFFF;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.btn:hover {
  background: #0B48CF;
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn:focus-visible {
  outline: 2px solid #2563EB;
  outline-offset: 2px;
}

Generating runs in your browser. What you type never leaves this device.

Features

  • Six styles: solid, outline, soft, ghost, gradient and neo-brutal

  • Hover effects: darken, lift, glow ring or none; press feedback included

  • Focus-visible outline for keyboard users, in your brand colour

  • Text colour picked for contrast (white or near-black)

  • Corner radius up to a full pill, padding, font size, weight and uppercase

  • Copy CSS with a class name you choose, HTML, or a Tailwind button

Buttons for every job

Call-to-action buttons

A solid or gradient "Book a demo" or "Buy now" button in your brand colour.

Secondary actions

Outline, soft and ghost buttons for "Learn more" or "Cancel" next to the main button.

Email and landing pages

Plain CSS you can paste into a page builder, WordPress custom CSS or an HTML email (simple styles).

Button design tips

One main button per screen

Use the solid or gradient style for the single most important action and quieter styles (outline, soft, ghost) for the rest. Two loud buttons side by side compete for attention.

Size and spacing

  • Make buttons at least 44 px tall on phones so they are easy to tap.
  • Side padding about twice the top and bottom padding looks balanced.
  • Use a verb on the label: "Download invoice" beats "Submit".

Do not remove the focus ring

Keyboard users need to see where they are. The CSS uses :focus-visible, so the ring appears for keyboard navigation but not on mouse clicks.

Related tools

CSS Button Generator - FAQ