UCSSR

Button Generator

Design beautiful, customizable buttons with real-time preview

Normal State
sm
md
lg
6px
16px
8px
Generated CSS

Ready to use in your project

Format:
1.button {
2 /* Base styles */
3 display: inline-flex;
4 align-items: center;
5 gap: 0.5rem;
6 border-radius: 6px;
7 padding: 8px 16px;
8 font-size: 1rem;
9 font-weight: 500;
10 transition: all 0.2s ease;
11 cursor: pointer;
12 
13 /* Variant: solid */
14 background-color: #3B82F6;
15 color: #FFFFFF;
16 border: none;
17 box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
18}
19 
20.button:hover {
21 background-color: #2563EB;
22 color: #FFFFFF;
23 transform: translateY(-1px);
24}
25 
26.button:disabled {
27 opacity: 0.5;
28 cursor: not-allowed;
29 transform: none;
30}
31 
32.button:focus-visible {
33 outline: 2px solid #3B82F6;
34 outline-offset: 2px;
35}
Button Design Guide
Best practices for creating effective button designs

Buttons are the primary way users interact with your application. A well-designed button system creates clear visual hierarchy, improves usability, and guides users through your interface.

1Button Hierarchy

Primary (Solid)

Main CTAs, form submissions, completing processes

Use sparingly - typically one per section

Secondary (Outline)

Alternative actions, cancel buttons, supporting actions

Great for secondary options alongside primary buttons

Tertiary (Ghost)

Toolbar actions, card actions, dense UI areas

Subtle presence, useful for multiple actions

Link

Navigation, inline text actions, help links

Use when action is similar to navigation

2Size Guidelines

SizeHeightBest For
Small32pxDense UIs, toolbars, inline actions
Medium40pxDefault for most actions
Large48pxHero CTAs, important actions

3Interactive States

Hover

Darken/lighten, slight transform

Focus

Visible focus ring for accessibility

Active

Pressed state with scale effect

Loading

Spinner, disabled interaction

4Accessibility Requirements

Visual

  • 4.5:1 minimum contrast ratio for text
  • 44x44px minimum touch target
  • Visible focus indicators

Semantic

  • Use proper <button> elements
  • Add aria-labels for icon buttons
  • aria-busy for loading states

5Best Practices

Do

  • Use action-oriented text ("FloppyDisk Changes")
  • Maintain consistent styling
  • Provide visual feedback for all states
  • Make buttons large enough for touch
  • Use icons to enhance clarity

Don't

  • Use vague text ("Click Here")
  • Overuse primary buttons
  • Ignore disabled state styling
  • Skip loading indicators
  • Mix inconsistent styles

6Common UI Patterns

Form Actions

SubmitCancel

Primary right, secondary left

Dialog Actions

ConfirmCancel

Destructive actions in red

Toolbar

Icon buttons

Ghost variant, grouped together

What is CSS Button Generator?

CSS buttons are styled using properties like `background-color`, `border`, `border-radius`, `padding`, `color`, `font-size`, and `box-shadow`. Modern buttons include hover and focus states for interactivity, transitions for smooth state changes, and proper focus indicators for keyboard accessibility. Well-designed buttons communicate clickability and provide clear visual feedback, making them one of the most important interactive elements in web interfaces.

Read the full CSS Button Styles guide

Tips & Best Practices

  • 1Always include a `:focus-visible` style for keyboard accessibility — never just remove the outline.
  • 2Use `transition` (200-300ms) on hover/active states for smooth, professional-feeling interactions.
  • 3Set `cursor: pointer` on buttons styled as links and `cursor: not-allowed` on disabled buttons.
  • 4Use `min-height: 44px` and `min-width: 44px` to meet touch target size guidelines.
  • 5Avoid using only color to indicate button state — add border, shadow, or scale changes for color-blind users.
  • 6Use `appearance: none` and reset default browser styles before applying custom styles to `<button>` elements.

Frequently Asked Questions

Use the `:hover` pseudo-class to change properties like background-color, box-shadow, or transform. Add a `transition` property to the base state (e.g., `transition: all 0.2s ease`) so the change animates smoothly.

A `<button>` element triggers actions (submit form, toggle UI, run JavaScript). An `<a>` element navigates to a URL. Always use the semantic HTML element — style it however you want, but use `<button>` for actions and `<a>` for navigation.

Set `background-color: transparent`, add a `border` (e.g., `border: 2px solid currentColor`), and set the text `color`. On hover, fill the background and change the text color for contrast.

Ensure sufficient color contrast (4.5:1 for text), provide visible focus indicators (`:focus-visible`), use semantic `<button>` elements, include descriptive text or aria-label, and ensure touch targets are at least 44x44 pixels.

Use `background-image: linear-gradient(...)` instead of `background-color`. For hover effects, you can shift the `background-position` (size the gradient larger than the button) or layer a semi-transparent overlay.