HomeToolsGeneratorsCSS Gradient Generator

CSS Gradient Generator

Design custom CSS linear and radial gradients visually, manage color stops, and export CSS/Tailwind code.

Generators
Live Gradient Preview

Gradient Settings

0%
100%
CSS Background Code
background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
Tailwind CSS Arbitrary Class
bg-[linear-gradient(135deg,_#ec4899_0%,_#8b5cf6_100%)]

Start With the Surface, Not the Code

A CSS gradient is a browser-rendered image made from color transitions. This visual CSS gradient generator lets you compose that image, see it on a large preview, and copy either a complete background declaration or a Tailwind arbitrary-value class. It supports linear and radial gradients, two to ten color stops, and exact stop positions from 0% to 100%.

Begin by deciding what the gradient must do. A subtle card background needs low contrast and restrained saturation. A hero backdrop can tolerate wider color movement. A data overlay needs enough local contrast for labels. The live preview shows the color field, but it does not test text readability, animation, print output, or dark-mode adaptation.

The initial composition is a 135-degree linear transition from pink at 0% to violet at 100%. Every control updates the preview and both code blocks immediately.

Build a Linear Gradient

Select Linear under Gradient Type. The angle slider ranges from 0° to 360°. CSS angles follow a compass-like convention: 0° points upward, 90° points right, 180° points down, and 270° points left. A 135° line therefore travels toward the lower-right direction. This can feel different from angles in drawing applications, so use the preview rather than relying on intuition alone.

Each color stop has four relevant controls: a native color picker, editable hex text, a position slider, and a delete button. Position determines where that color is exact along the gradient line. With blue at 0%, purple at 50%, and orange at 100%, the browser interpolates blue-to-purple over the first half and purple-to-orange over the second.

Stops are sorted by position when code is generated, even if their rows appear in creation order. Two stops may occupy the same percentage. That creates a hard transition rather than a smooth blend, a useful technique for striped panels or sharp section boundaries. Reversing stop positions changes rendered order without rearranging the editor rows.

Add Stop creates a random color near the average existing position plus ten percentage points, clamped between 5% and 95%. It does not place the new stop in the largest visual gap. Reposition it deliberately. The button stops at ten colors, and deletion is disabled when only two remain because a gradient needs at least two stops in this editor.

Shape a Radial Gradient

Switch Gradient Type to Radial. The angle control disappears and Shape offers circle or ellipse. Circle expands with equal radial geometry; ellipse adapts differently across rectangular surfaces. Position sets the origin to center, a side, or one of four corners.

A radial highlight for a card might use a light accent at top left, a base surface around 45%, and a darker edge at 100%. The generator produces syntax such as:

background: radial-gradient(circle at top left, #f8fafc 0%, #64748b 45%, #0f172a 100%);

The editor does not expose radial size keywords such as closest-side, farthest-corner, or explicit radii. It also cannot enter a custom origin like 35% 20%; only the nine listed positions are available. If a design requires those controls, copy the generated CSS and refine it manually.

Presets and Randomization Serve Different Purposes

Five presets provide reproducible starting points: Sunset Glow, Ocean Breeze, Neon Dreams, Cotton Candy, and Aurora Borealis. Loading one switches to its linear type, angle, colors, and positions. Aurora Borealis demonstrates a three-stop gradient with a midpoint at 50%; the others use two stops.

Randomize chooses an angle from 0° through 360° and creates two to four random colors at evenly spaced positions. If the current type is radial, it remains radial; the randomized angle is stored but has no visible effect until Linear is selected. Radial shape and origin also remain unchanged. Random output is useful for exploration, not controlled palette harmony, contrast, or brand compliance.

Presets overwrite the current stops without an undo facility. Copy valuable code before trying another preset or randomizing.

Understand the Two Exports

The CSS block includes the property name and semicolon:

background: linear-gradient(90deg, #06b6d4 0%, #3b82f6 100%);

Paste it inside a CSS declaration block. If a component already uses a background color, image, position, or size, remember that the background shorthand can reset related sub-properties. Change it to background-image: linear-gradient(...) manually when preserving other background settings is important.

The Tailwind block wraps the gradient function in an arbitrary background class and replaces whitespace with underscores:

bg-[linear-gradient(90deg,_#06b6d4_0%,_#3b82f6_100%)]

Whether that class compiles depends on the Tailwind version, content scanning, framework templating, and class-name handling. Dynamically constructing arbitrary classes at runtime may prevent Tailwind from discovering them. Keep the full literal in source or add it to the appropriate safelist when required. Some templating contexts also need escaping.

Both copy buttons use browser clipboard access. The tool exports one standard declaration and one class; it does not generate vendor-prefixed fallbacks, Sass variables, image files, or design-tool formats.

Designing Stops With Intent

Evenly spaced stops do not guarantee an even-looking blend. sRGB interpolation and differing perceived luminance can create a muddy center between complementary colors. Add an intentional midpoint color to guide the transition, or move stops to shorten the unattractive region. Highly saturated colors may produce banding on some screens, especially over large dark areas.

For a highlight behind text, place the quietest region under the copy and test every responsive crop. The preview is a fixed-height rectangle; the same gradient changes appearance on a tall phone panel or a very wide banner because percentages resolve against different geometry.

Gradient text contrast varies across position. A white heading that works over the dark end may disappear over a pale stop. Test the worst point, not an average color. A translucent overlay can stabilize contrast, but this generator’s stop inputs accept six-digit native-picker colors and provide no alpha slider. Add eight-digit hex, rgb(... / alpha), or a separate overlay after export if needed.

Limitations and Failure Checks

Text fields for stop colors are passed directly into generated CSS. Invalid color text can make the preview or declaration fail; there is no dedicated error banner. The native color picker always supplies valid six-digit hex, so use it to recover from malformed text.

The generator has no conic gradients, repeating gradients, stop hints, alpha editor, blend modes, layered backgrounds, gradient animation, or saved history. It cannot import an existing CSS gradient for editing. Stop positions are integer percentages only. Browser rendering determines interpolation and may show slight visual differences across display pipelines.

Common errors include assuming row order equals rendered order, pasting the background: declaration where only a value is allowed, using the Tailwind class in dynamically concatenated code, and treating random colors as accessibility-safe. Another is deleting a stop and thinking the disabled trash icon is broken; the minimum is intentionally two.

CSS Gradient Generator FAQ

How many color stops can I add?

From two through ten. Add is disabled at ten, and remove is disabled at two.

Can two stops share a position?

Yes. The generated CSS sorts them but preserves equal-position stops, which can produce a sharp color edge.

Does Randomize switch radial gradients back to linear?

No. It changes colors, positions, and the stored angle while retaining the selected gradient type.

Can I set transparency?

There is no alpha control, and the native picker uses opaque hex. Edit the copied CSS with alpha-capable color syntax if transparency is required.

Why does the Tailwind class not appear in production?

Ensure the exact class exists statically in files scanned by Tailwind and that your version supports arbitrary background values. Runtime string construction is a frequent cause of missing generated CSS.

Are gradients resolution independent?

Browsers render CSS gradients for the element’s current size, so they do not pixelate like a small raster asset. Displays can still show color banding, and print or screenshot output is rasterized at export time.

Can I reopen copied CSS in this editor?

No import parser is provided. Recreate the type, angle or radial settings, colors, and percentages using the controls.

Learn More

Read our comprehensive guide to master this utility.

Read Guide →