CSS Button Generator
Design and generate custom CSS button styles with live preview and instant code export.
Updated
What is the CSS Button Generator?
The CSS Button Generator is a free, browser-based tool that lets you design pixel-perfect button styles visually and export production-ready CSS in seconds — no design software, no hand-coding required.
Tweak every visual property through live controls: background color, gradient direction, typography, padding, border radius, box shadow, hover state, active press effect, and transition easing. The interactive preview updates in real time so you can see exactly how your button looks and behaves — including hover animations, focus rings, and press scaling — before copying a single line of code.
What you can generate
- Solid, gradient, ghost, outline, soft, and pill button variants
- Full pseudo-class coverage —
:hover,:focus-visible,:active, and:disabledrules baked in - Three export formats — CSS class (drop into your stylesheet), JSX inline
style={{}}(paste into React), and HTMLstyle=""(for plain HTML pages) - Accessible defaults — focus rings,
user-select: none, smoothtransitionon all interactive properties, andpointer-events: noneon disabled states
Whether you're building a landing page, a design system, or a quick prototype, this tool eliminates the trial-and-error of writing button CSS by hand and ensures every state is accounted for before you ship.
How it works
1. Choose a preset (optional)
Start from one of the built-in presets — Primary, Secondary, Ghost, Danger, Success, Gradient, Dark, Pill, Soft, Outline, Glow, or Bounce — to get a solid baseline in one click. You can then fine-tune every property from there, or click Reset to return to the default blue primary button at any time.
2. Adjust the controls
The controls panel is organized into labeled sections so you can find any property quickly:
| Section | What you can change |
|---|---|
| Background | Solid colour or two-stop gradient with angle control |
| Text | Colour, size, weight, transform (uppercase etc.), letter spacing |
| Spacing & Shape | Horizontal and vertical padding, border radius (0 → pill) |
| Border | Style (solid, dashed, dotted, double, none), colour, and width |
| Box Shadow | X/Y offset, blur, spread, colour, opacity, and inset toggle |
| Hover State | Background, text colour, border colour, and an independent hover shadow |
| Active & Press | Background colour and a scale factor for a press-down feel |
| Transition | Duration in milliseconds and easing (including a spring / overshoot curve) |
| Layout | inline-flex vs flex, and a full-width toggle |
3. Watch the live preview
Every change instantly updates two interactive previews — one on a light background and one on a dark background. Hover and click directly on the preview buttons to see your transitions and press animations in action.
Below the interactive previews, a States grid shows static snapshots of all five button states side by side: Normal, Hover, Active, Focus, and Disabled, plus a full-width variant.
4. Edit the preview label
Type any text into the Preview Label field to see how the button looks with real content — short labels like "OK", medium labels like "Get Started", and longer ones like "Download the free report" all affect perceived padding and proportion.
5. Export your code
Switch between three output formats using the tab control above the code editor:
- CSS class — A complete
.btn { … }block with:hover,:focus-visible,:active, and:disabledrules. Edit the class name in the input field. Copy to clipboard or download as a.cssfile. - JSX inline — A
style={{ … }}object string ready to paste onto a React<button>element. - HTML inline — A
style="…"attribute string for plain HTML.
Use the copy button in the top-right corner of the code panel, or the Download .css button below it for the full CSS export.
Examples
Primary Call-to-Action Button
A solid blue primary button with a subtle hover darkening effect, ideal for main CTAs like "Get Started" or "Sign Up".
Ghost / Outline Button
A transparent button with a visible border and colored text, commonly used as a secondary action alongside a primary button.
Gradient Button with Glow Shadow
A blue-to-purple gradient button with a colored box-shadow on hover, great for hero sections and feature highlights.
Pill Button with Spring Animation
A fully rounded pill-shaped button that bounces on hover using a cubic-bezier spring easing, perfect for playful or modern UIs.
Frequently asked questions
What is a CSS button generator?
What is a CSS button generator?
A CSS button generator is an online tool that lets you design custom button styles visually — adjusting colors, borders, shadows, padding, and more — and then exports the ready-to-use CSS code. Instead of writing and tweaking CSS rules by hand, you get instant visual feedback and production-ready output in seconds.
Does the generated CSS work in all browsers?
Does the generated CSS work in all browsers?
Yes. The generated CSS uses standard, widely-supported properties (background, border-radius, box-shadow, transition, transform) that work in all modern browsers including Chrome, Firefox, Safari, and Edge. The code also includes -webkit-font-smoothing: antialiased for better text rendering on macOS and iOS. IE 11 is not supported, but IE 11 has been end-of-life since 2022.
What button states does the generator cover?
What button states does the generator cover?
The generator produces CSS rules for all five interactive states:
- Normal — the default appearance
- :hover — triggered when the user moves the cursor over the button
- :focus-visible — keyboard focus ring shown only when navigating with a keyboard (accessibility-friendly)
- :active — the pressed state, including an optional scale-down animation
- :disabled / [aria-disabled="true"] — reduced opacity and
pointer-events: none
Can I use the generated CSS in React, Vue, or plain HTML?
Can I use the generated CSS in React, Vue, or plain HTML?
Yes. The tool exports three formats:
- CSS class — paste into any
.css,.scss, or<style>block and apply the class to your element - JSX inline style — paste the
style={{ … }}prop directly onto a React<button>component - HTML inline style — paste the
style="…"attribute into a plain HTML<button>tag
How do I create a gradient button?
How do I create a gradient button?
Enable the Use gradient toggle in the Background section. A second colour picker and an angle slider will appear. Set your start colour, end colour, and gradient angle to produce a linear-gradient() background. The hover state will automatically darken both gradient stops to give a natural hover effect.
How do I make a pill-shaped button?
How do I make a pill-shaped button?
Set the Border radius slider to its maximum value (9999 px). The generated CSS will include border-radius: 9999px, which produces a fully rounded pill shape regardless of the button's height. You may also want to increase the horizontal padding (Padding X) to give the text more breathing room inside the pill.
What is the difference between the CSS class and inline style outputs?
What is the difference between the CSS class and inline style outputs?
The CSS class output is a full stylesheet block including :hover, :focus-visible, :active, and :disabled pseudo-class rules. It requires a separate stylesheet or <style> tag and is the recommended approach for reusable, accessible buttons.
The inline style output (JSX or HTML) only captures the base appearance — pseudo-class states cannot be expressed as inline styles in HTML. Use inline styles when you need a one-off quick override and are handling hover/focus states separately (for example, with a React useState or CSS Modules).
Can I add a box shadow or glow effect?
Can I add a box shadow or glow effect?
Yes. Enable Box Shadow in the shadow section and adjust the X offset, Y offset, blur, spread, colour, and opacity independently. For a glow effect, set X and Y to 0, increase the blur radius, and choose a colour that matches the button background. You can also enable a separate Hover shadow so the glow only appears on hover.
How do I control the hover animation speed?
How do I control the hover animation speed?
Use the Duration slider in the Transition section to set the animation length in milliseconds (0–800 ms). The Easing dropdown lets you choose the acceleration curve: ease, ease-in, ease-out, ease-in-out, linear, or the Spring / overshoot curve (cubic-bezier(0.34, 1.56, 0.64, 1)) for a bouncy, playful feel.
What does "active scale" do?
What does "active scale" do?
The Press scale slider in the Active & Press section applies a transform: scale() to the button when it is clicked and held. A value below 1.0 (for example, 0.97) creates a subtle press-down effect that gives the button a tactile, physical feel. Set it to 1.0 to disable the scale transform entirely.
Is my data sent to a server?
Is my data sent to a server?
No. The CSS button generator runs entirely in your browser. No configuration data, colour values, or generated code is ever sent to a server or stored anywhere outside your local browser tab. All processing happens client-side in JavaScript.
Can I save my button configuration?
Can I save my button configuration?
The tool does not currently save configurations between sessions. To preserve a design, copy the generated CSS class output and store it in your project — the CSS block fully encodes the visual state of your button and can be pasted back into any stylesheet.
Why should I use a CSS button generator instead of a UI library?
Why should I use a CSS button generator instead of a UI library?
CSS button generators give you full control over every visual detail without the overhead of installing a component library. They are ideal when you need a one-off custom button that matches a specific brand, when you are working in a framework-agnostic environment, or when you want to understand exactly what CSS is being applied. For large design systems with many components, a UI library may be more appropriate.
What is the :focus-visible rule in the generated CSS?
What is the :focus-visible rule in the generated CSS?
:focus-visible is a modern CSS pseudo-class that shows a focus indicator only when the element is focused via keyboard navigation — not when clicked with a mouse. This improves accessibility (keyboard users always see where focus is) without showing a distracting outline on every mouse click. It is supported in all modern browsers and is the recommended approach over the older :focus selector for visible focus rings.
Related tools
More utilities you might find handy.
Box Model Visualizer
Interactive CSS box model visualizer with real-time editing of margin, border, padding, and content dimensions
CSS Animation Generator
Generate CSS keyframe animation code
CSS Clip Path Generator
Generate responsive CSS clip-path shapes with a visual polygon editor and instant CSS code.