Skip to main content
BG

Button Generator

Complete button styler — colours, borders, padding, shadows, hover state, and a live editable preview.

Did you like the tool? Thanks!
Share:

More CSS Tools

BS

Box Shadow Generator

Build pixel-perfect box shadows with live preview — control offsets, blur, spread, colour, and opacity, then copy the CSS in one click.

BR

Border Radius Generator

Shape rounded corners visually — control all four corners independently or link them together, with instant preview and CSS output.

TS

Text Shadow Generator

Add depth to your typography — control shadow offset, blur, colour, and preview on custom text with live CSS output.

GT

Gradient Text Generator

Transform plain text into vibrant gradient typography — choose colours, direction, and preview live with ready-to-use CSS.

CV

CSS Variables Generator

Define and preview CSS custom properties in real time — build your :root block visually and see variables applied to a sample card component.

CG

CSS Grid Generator

Visual CSS Grid builder — set rows, columns, gaps, and alignment, then copy the exact grid CSS in one click.

FG

Flexbox Generator

Visual Flexbox playground — choose direction, alignment, wrapping, and gap; see numbered items rearrange live.

CA

CSS Animation Generator

Build CSS @keyframes animations visually — choose from 7 preset templates, tweak every parameter, and see your animation play live.

HC

Hover Card Generator

Design cards with smooth hover effects — lift, scale, shadow, and border transitions, all previewed live on a sample card.

SA

Scroll Animation Generator

Build scroll-triggered animations — elements fade and slide into view as the user scrolls, powered by Intersection Observer.


    

How to Use Button Generator

Design every aspect of a button visually: background and text colours with native colour pickers, editable button text, font size (12–40 px) and font weight (normal, bold, bolder), individual padding controls for each side (0–40 px), border width (0–8 px) with a separate border colour picker, border radius (0–50 px), a toggleable box shadow with horizontal/vertical offset, blur, spread, and colour controls, cursor style (pointer, default, not-allowed), and button width (auto or full-width). Below the main controls, separate hover-state colour pickers let you define how the button changes on mouseover. The preview panel shows a live button with your current styling, including the hover state that activates when you mouse over the preview. The CSS output contains both the normal `.custom-button` rule and the `.custom-button:hover` rule, and a Copy CSS button grabs both rules at once.

About Button Generator

Buttons are the most interactive element on the web. Every call to action — Subscribe, Buy, Submit, Download, Sign Up — is a button, and its visual design directly affects whether users click it. A well-styled button communicates its purpose through colour (primary actions in a brand colour, destructive actions in red, subtle actions in grey or outlined), its state through visual feedback (hover, focus, active, disabled), and its importance through size, weight, and spacing. Getting buttons right is not just a matter of aesthetics; it is a conversion optimisation task. Studies consistently show that button colour, size, and wording have measurable effects on click-through and completion rates. This tool breaks button styling into its constituent CSS properties and lets you adjust each one independently, with a live preview that shows the result immediately. Rather than bouncing between your code editor and browser — change a colour, save, refresh, squint, repeat — you can dial in the exact appearance in one session and copy the finished CSS. **Colours:** The background colour is the most prominent design decision. Brand colours are the default choice for primary buttons, but what about the hover state? A common pattern (and the default in this tool) is to darken the background slightly on hover — perhaps by 10-15% — which provides a clear visual signal that the button is interactive. The text colour must maintain sufficient contrast against the background for legibility (WCAG AA requires a 4.5:1 ratio for normal text — use this project's Contrast Checker tool to verify your colour choices). The border colour is independent of the background, allowing for outlined button designs where the border is the primary visual element and the background is transparent or matches the page. **Typography:** Font size and font weight together determine the button's visual weight and its position in the visual hierarchy. A 14 px normal-weight button says "secondary action" or "I am available if you need me"; a 20 px bold button says "this is the main thing you should do on this page." The text content itself — editable in the preview — is arguably more important than any visual property. "Buy Now" converts differently from "Purchase" — being able to edit the text in the preview lets you test wording alongside styling. **Spacing and shape:** Padding creates the clickable area — generous padding (12–24 px) makes a button easier to target on touch screens and communicates importance. The individual-side padding controls (top, right, bottom, left) let you create non-uniform padding, though for most buttons equal horizontal and vertical padding looks most balanced. Border radius controls the roundness: 0 px gives a sharp, technical, no-nonsense rectangular button; 4–8 px gives a soft, modern, friendly button; 50 px on a narrow button creates a pill shape. Border width controls whether the button has a visible outline (2+ px), a subtle outline (1 px), or no outline (0 px, where the border is effectively absent). **Shadows:** box-shadow is the quickest way to add depth and elevate a button above the page surface. A small offset (0 2px 4px) with a semi-transparent black colour creates a subtle lift; a larger offset with more blur creates a floating, call-to-action button. The spread parameter (rarely changed but included for completeness) expands or contracts the shadow in all directions. The tool lets you toggle the shadow on and off and adjust each parameter independently. **Hover state:** The hover pseudo-class (`.custom-button:hover`) is essential for interactive feedback. Without a hover state, a button looks static and unresponsive — users cannot tell whether it is clickable until they try clicking. The most common hover effect is a background colour shift (lighter or darker, depending on the design). Changing the text colour on hover is less common but can create striking effects (e.g., a filled button that inverts to become outlined on hover). The border colour can also shift on hover to increase the visible outline. This tool generates separate CSS blocks for the normal and hover states, so you can define any combination of these changes. **Cursor:** The `cursor` property tells the browser what mouse pointer to display. `pointer` (hand/finger) is the standard for clickable buttons. `default` (arrow) is appropriate for a button that looks interactive but has been disabled. `not-allowed` (circle-with-slash) is the standard for disabled-state buttons and should always be paired with a visual indicator of disabled state (reduced opacity, greyed-out colours). **Button width:** `auto` lets the button size to its content width (with padding). `width: 100%` (full-width) makes the button fill its container, which is useful for mobile layouts, form submit buttons, or any call to action that should span the full card or section width. The history of the `button` element is a story of progressive styling capabilities. In the early web, buttons were rendered by the operating system — a grey Windows 95-style button on Windows, a glossy Aqua button on Mac OS — and CSS had almost no control over their appearance. The `appearance: none` property (initially vendor-prefixed as `-webkit-appearance: none` and `-moz-appearance: none`) was the turning point: it told the browser to discard the native OS styling and render the button as a blank canvas that CSS could fully control. Today, stripping native button styles and rebuilding them with custom CSS is the standard practice, and tools like this one are used to design the result.

Details & Tips

Generated CSS structure and property reference: ```css .custom-button { background-color: #3B82F6; color: #FFFFFF; font-size: 16px; font-weight: bold; padding: 12px 16px 12px 16px; border: 2px solid #2563EB; border-radius: 8px; box-shadow: 0 2px 4px 0px rgba(0,0,0,0.1); cursor: pointer; width: auto; display: inline-block; text-align: center; transition: background-color 0.2s, color 0.2s, border-color 0.2s; } .custom-button:hover { background-color: #2563EB; color: #F0F0F0; } ``` **Property reference:** - `background-color`: The fill colour of the button. Accepts hex, rgb(), hsl(), or named colours. Use a colour picker for visual selection. - `color`: The text (foreground) colour. Must contrast with background-color for legibility. - `font-size`: The text size in pixels. 16 px is the browser default for body text; 14-18 px is typical for buttons. - `font-weight`: normal (400), bold (700), or bolder (relative to parent — usually 900). Bold makes the text visually heavier. - `padding`: Clockwise order: top, right, bottom, left (TRBL — "trouble" mnemonic). Each side can be set independently via the four slider inputs. - `border`: Shorthand for width, style (solid), and colour. A border of 0 px width still renders if colour is set — to truly remove the border, set width to 0. - `border-radius`: Corner rounding in pixels. 50 px on a 40-px-tall button creates a fully rounded pill shape. - `box-shadow`: Format: `offsetX offsetY blurRadius spreadRadius colour`. offsetX moves the shadow right (positive) or left (negative). offsetY moves it down (positive) or up (negative). blurRadius softens the edges (0 = sharp). spreadRadius expands (positive) or contracts (negative) the shadow. - `cursor`: `pointer` shows a hand, `default` shows an arrow, `not-allowed` shows a prohibition symbol. - `width`: auto (fits content) or 100% (fills parent container). - `display: inline-block`: Allows the button to sit inline with text but accept padding and width like a block element. - `text-align: center`: Centres the button text horizontally. - `transition`: Smoothly animates colour changes on hover. The 0.2s duration is a sensible default — shorter feels abrupt, longer feels sluggish. **The transition property is hardcoded** because it is almost always desirable to have smooth hover transitions — without it, the colour switch is instantaneous and can feel jarring. If you prefer an instant change, remove the `transition` line from the copied CSS. **Hover state specifics:** The hover rule includes only the properties that commonly change on hover: `background-color` and `color`. The transition on the normal state handles the animation between the two colour values. If you set the hover colours identical to the normal colours, the button will not visually change on hover — this can be intentional for buttons that are decorative rather than interactive. **Preview interaction:** The preview button is a live `<button>` element. Mousing over it applies the hover colours; mousing out restores the normal colours. The button text is editable — click the text directly to change it (the preview uses a `contenteditable` span for text editing, which is safe because it only affects the preview text, not the CSS). The cursor style is visible when you hover over the preview button — the mouse pointer changes to match the chosen cursor value. **Edge cases handled:** - Border width of 0 removes the border despite any colour setting, preventing invisible borders from occupying space. - Padding values clamp to 0-40 px; negative values are ignored. - Font size clamps to 12-40 px to prevent unreadable or comically large text. - Border radius clamps to 0-50 px. - When box shadow is toggled off, the `box-shadow` property is omitted from the CSS entirely rather than set to `none` (cleaner output). - Full-width mode (`width: 100%`) combined with auto-width parent may cause the button to extend beyond the preview panel — a `max-width: 100%` is applied to the preview container as a safeguard.

Frequently Asked Questions

How do I use the Button Generator?
Adjust the controls — colours (background, text, border), font size and weight, padding (each side), border width and radius, shadow, hover colours, cursor, and width. The preview button updates live. Click Copy CSS to get both the normal and hover CSS rules.
How do I set the hover state colours?
Use the dedicated hover colour pickers in the Hover State section. The hover background and text colours are stored separately from the normal state colours, and the generated CSS includes a separate `.custom-button:hover` rule.
Can I edit the button text in the preview?
Yes — the preview button text is editable directly. Click the text on the button in the preview panel and type your own label. This only affects the preview, not the generated CSS.
What does the box shadow toggle do?
When enabled, the box-shadow controls appear and the generated CSS includes the shadow values. When disabled, the shadow controls are hidden and no box-shadow property is included in the CSS output.
What do the four padding sliders control?
They set the padding for each side of the button independently — top, right, bottom, and left — using the CSS TRBL (Top-Right-Bottom-Left) order. On most buttons equal top/bottom and left/right padding looks best.
What is the difference between cursor: pointer, default, and not-allowed?
pointer shows a hand/finger (standard for clickable buttons). default shows an arrow (for static elements). not-allowed shows a prohibition symbol (for disabled buttons — should always be paired with a visual disabled state).
What does width: auto vs 100% do?
auto sizes the button to fit its text content plus padding. 100% (full-width) makes the button stretch to fill the width of its parent container, which is useful for mobile layouts and form submit buttons.
Why does the generated CSS include a transition property?
The `transition: background-color 0.2s, color 0.2s` line smoothly animates the colour change when the user hovers over the button. Without it, the colour would switch instantly, which can feel abrupt. You can remove the transition line if you prefer an instant change.
Does the button work on mobile and touch devices?
Yes — the generated CSS is standard and works on all devices. Touch devices do not have a true hover state, but the `:hover` styles will apply on tap-and-hold, and the button remains fully functional.
Can I create an outlined button (transparent background, coloured border)?
Yes — set the background colour to transparent (use the colour picker or type \"transparent\" manually), set the border width to 2 px or more, and choose a visible border colour. For the hover state, you could fill the background with the border colour.
What if I want different hover changes — like border colour or shadow?
The tool generates hover rules for background-colour and colour only. If you need additional hover properties (border colour, shadow, transform), add them manually to the `.custom-button:hover` rule in your stylesheet after copying.
Is my data sent to a server?
No — the button preview and CSS generation run entirely in your browser using JavaScript. Nothing you configure is transmitted anywhere.

Part of These Collections

Also Available As

button generator, css button, button styler, button css, button design, hover button, button shadow, button border, button padding, css button generator, custom button, call to action button

Found a Problem?

Let us know if something with Button Generator isn't working as expected.

Thanks — we'll take a look.