Skip to main content
GG

Gradient Generator

Build live CSS gradients — Linear, Radial, and Conic — with multiple colour stops, angle control, and copyable CSS output.

Did you like the tool? Thanks!
Share:

Minimum 2 stops required for a gradient.


    

How to Use Gradient Generator

Design CSS gradients visually with an interactive preview and generated code. Choose gradient type (Linear, Radial, Conic), set the angle for linear gradients with a slider or circular picker, and add or remove colour stops (2 to 5). Each stop has a colour picker and a position percentage. The preview updates live as you adjust any control, and the generated CSS code is displayed below ready to copy.

About Gradient Generator

CSS gradients are one of the most powerful yet underused visual tools in modern web design. A gradient can replace an image for backgrounds, overlays, buttons, and decorative elements — saving bandwidth, improving performance, and being infinitely resolution-independent. But writing gradient CSS by hand is tedious: you need to remember the syntax (background vs background-image, the angle convention, the comma-separated colour stops), mentally visualise what a set of stops will look like, and then refresh the browser to check. This tool replaces that trial-and-error loop with a live interactive builder. Three gradient types are supported, matching the three CSS gradient functions: - **Linear gradient:** Colours transition along a straight line at a specified angle. Angles are measured in degrees clockwise from the top (the CSS convention: 0deg = bottom-to-top, 90deg = left-to-right, 180deg = top-to-bottom, 270deg = right-to-left). This is the most commonly used gradient type — for hero sections, button backgrounds, and subtle shading. - **Radial gradient:** Colours radiate outward from a central point in an elliptical or circular shape. The tool uses the `circle` keyword for simplicity. Radial gradients are perfect for spotlight effects, vignettes, and circular badges. - **Conic gradient:** Colours rotate around a central point like the slices of a pie chart or a colour wheel. Conic gradients are newer (supported in all modern browsers since 2020-2021) and are ideal for progress rings, loading indicators, and pie-chart-style visualisations. **Colour stops** define the transition. Each stop has a colour (set via a native `<input type="color">` picker) and a position (a percentage from 0% to 100% that specifies where on the gradient line that colour should appear). The tool enforces a minimum of 2 stops (with 2 stops, you have a simple two-colour gradient) and a maximum of 5 stops (additional stops let you create complex, multi-colour gradients with precise control over colour placement). Stops are automatically sorted by position before rendering and before generating the CSS string. The preview area is a `<div>` element whose background-image is set to the generated CSS gradient string — this means what you see in the preview is exactly what CSS will render in a browser, pixel-for-pixel. There is no approximation, no canvas drawing, no image generation — the browser's own CSS gradient engine renders the preview, so it is 100% accurate. Below the preview, the generated CSS code is displayed in a monospace code block with a Copy button, so you can grab the exact `background:` or `background-image:` declaration and paste it into your stylesheet. **Angle control for linear gradients:** A number input lets you type any angle from 0 to 360 degrees. A slider provides a quick drag-to-adjust experience. The preview updates live on every input event — you see the gradient rotating in real time.

Details & Tips

CSS output format by type: **Linear:** `background: linear-gradient(45deg, #ff0000 0%, #0000ff 100%);` - Angles from 0deg to 360deg. - Stops are comma-separated: `color position%`. **Radial:** `background: radial-gradient(circle, #ff0000 0%, #0000ff 100%);` - Always uses `circle` shape for simplicity (no ellipse control). - Same stop syntax as linear. **Conic:** `background: conic-gradient(#ff0000 0%, #00ff00 33%, #0000ff 66%, #ff0000 100%);` - Stops wrap around the full 360° circle. - Same stop syntax as linear and radial. **Stop position management:** - Positions are numbers 0-100 representing percentage positions along the gradient line. - Adding a stop: a new stop is inserted at a sensible default position (midway between existing stops, or 50% if only one stop exists). It defaults to a mid-grey colour to prompt the user to pick a colour. - Removing a stop: any stop can be removed, except when only 2 stops remain — the remove button is disabled with a tooltip explaining that a minimum of 2 stops is required for a gradient. - Dragging/reordering: stops are automatically sorted by position value before rendering. If you set a stop to position 80% and another to 20%, they render as 20% then 80%. - Clamping: positions below 0 are clamped to 0; positions above 100 are clamped to 100. **Edge cases and error handling:** - Attempting to remove the last remaining stop (when there are only 2) shows a tooltip or inline message: "A gradient needs at least 2 colour stops." - Duplicate position values: if two stops have the same position, they render in the order they appear in the stops array. This is CSS default behaviour. - Invalid hex codes for a stop colour: the widget does not validate individual stop hex codes because the colour picker always produces valid hex values. If you type an invalid hex in the text field, the browser ignores it and the preview may show a black/transparent segment — this is CSS behaviour. - All-identical colours: the preview shows a solid colour rectangle (the gradient is technically valid but visually indistinguishable from a solid fill). **Performance:** The preview is a pure CSS update — setting `this.$el.style.backgroundImage = cssString` on the preview div. Modern browsers optimise CSS background-image updates extremely well, so the preview feels instantaneous even with the `@input` event firing on every keystroke while dragging the angle slider or adjusting stop positions. No requestAnimationFrame, throttling, or debouncing is needed. **Accessibility note:** The preview div has a static background colour set to `white` as a fallback for browsers that do not support CSS gradients (though virtually all modern browsers do). The Copy button uses `navigator.clipboard.writeText()` for modern browsers with a synchronous `document.execCommand('copy')` fallback if Clipboard API is unavailable.

Frequently Asked Questions

How does the gradient generator work?
You choose a gradient type (linear, radial, or conic), set colour stops (each with a colour and a position percentage), and the preview updates live. The generated CSS code is displayed below with a Copy button.
What gradient types are supported?
Linear (colours along a straight line at a specified angle), Radial (colours radiating outward from a centre in a circle), and Conic (colours rotating around a centre like a pie chart). These match the CSS gradient functions.
How many colour stops can I have?
Minimum 2, maximum 5. You can add stops to create multi-colour gradients and remove stops to simplify. At 2 stops, the remove button is disabled — a gradient needs at least 2 colour stops.
How does the angle slider work for linear gradients?
A slider from 0 to 360 degrees lets you rotate the gradient line. 0deg = bottom-to-top, 90deg = left-to-right, 180deg = top-to-bottom, 270deg = right-to-left. The preview rotates in real time as you drag.
What do the position percentages mean for colour stops?
Each stop's position defines where on the gradient line that colour appears as a percentage of the total length. 0% is the start, 100% is the end. Stops are automatically sorted by position before rendering.
What happens if I set two stops to the same position?
They render in the order they appear in the stops list. CSS renders an abrupt colour change at that point — this can be used intentionally for hard-edge gradient effects.
Is the preview accurate to what CSS will render?
Yes — the preview is a `<div>` whose `background-image` is set to the exact CSS gradient string. The browser's own CSS rendering engine draws the preview, so it is 100% accurate to what you would see on a web page.
Why use a div for the preview instead of canvas?
Because we are generating CSS, and the only way to be 100% sure the CSS is correct is to let the browser render it. A canvas-based preview could differ from actual CSS rendering due to interpolation differences, colour-space handling, or anti-aliasing. The div preview is simpler and more accurate.
How do I copy the generated CSS?
Click the Copy button below the code block. The full CSS declaration (e.g. `background: linear-gradient(45deg, #ff0000 0%, #00ff00 100%);`) is copied to your clipboard.
Can I type hex codes for stop colours instead of using the picker?
Each stop has its own native colour picker. The picker produces valid hex codes. You can also type hex codes into the stop colour display if your widget variant exposes a text input for each stop colour.
What happens when I switch gradient types?
The angle slider appears only for linear gradients (radial and conic do not use an angle in this simplified tool). The preview and CSS output update immediately to reflect the new type.
Is my data sent to a server?
No — all gradient generation and preview rendering happens locally in your browser. Nothing is transmitted anywhere.

Part of These Collections

Also Available As

css gradient generator, gradient maker, linear gradient css, radial gradient css, conic gradient, gradient color stops, background gradient css, gradient angle picker

Found a Problem?

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

Thanks — we'll take a look.