CSS Button Generator
.button {
background: #3b82f6;
color: #ffffff;
padding: 12px 24px;
border-radius: 8px;
border: none;
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s ease;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
.button:hover {
background: #2563eb;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
transform: translateY(-1px);
}
.button:active {
transform: translateY(0);
}What is CSS Button Generator?
CSS Button Generator helps you create professional, customizable buttons for your website without writing code from scratch. This free tool lets you design buttons with custom colors, borders, shadows, padding, and hover effects. You can create everything from subtle, minimal buttons to bold, gradient-filled call-to-action buttons. Our generator provides real-time preview of both normal and hover states so you can see exactly how your button will look and feel. The generated CSS code is clean, modern, and ready to copy into your project. Perfect for creating consistent button styles across your website.
How to Use This Tool
Set the background color for your button
Choose a text color that contrasts well
Add a border if desired (or set width to 0)
Adjust padding for button size
Set border radius for rounded corners
Add box shadow for depth
Configure hover state colors
Copy the generated CSS code
Features
- Customize background color and text color
- Add borders with custom color and width
- Apply box shadow for depth and emphasis
- Set padding and border radius
- Create hover state with different colors
- Add smooth transition effects
- Real-time preview of normal and hover states
- One-click copy CSS button code
Frequently Asked Questions
- What makes a good button design?
Good buttons have clear visual hierarchy, sufficient padding (at least 12px vertical, 24px horizontal), readable text with good contrast, obvious clickability, and consistent hover/active states. They should look interactive and provide visual feedback.
- What is the best button color for conversions?
There is no universal best color - it depends on your design. The key is contrast: buttons should stand out from the background. Common choices are blue (trust), green (positive action), and orange (urgency). Test what works for your audience.
- How big should buttons be for mobile?
Apple recommends at least 44x44 pixels, Google recommends 48x48 pixels for touch targets. Ensure adequate padding and consider full-width buttons on mobile for easy tapping. Avoid buttons that are too close together.
- Should buttons have hover effects?
Yes, hover effects provide important feedback that an element is interactive. Common effects include color change, shadow increase, slight scale, or underline. Keep effects subtle (200-300ms) and ensure they work well with your design.
- What is the difference between button types (primary, secondary)?
Primary buttons are for main actions - they should be prominent with filled backgrounds. Secondary buttons are for less important actions - often outlined or more subtle. Ghost buttons are transparent with just a border. Use hierarchy to guide users.
- How do I make accessible buttons?
Use semantic <button> elements, ensure 4.5:1 contrast ratio for text, provide focus states for keyboard navigation, make buttons large enough to tap, use descriptive text (not just "Click here"), and test with screen readers.