CSS Tools

CSS Gradient Generator

Use this free CSS Gradient Generator to build linear, radial, and conic gradients visually and copy production-ready CSS in one click. Adjust colors, angles, and stop positions with a live preview, then paste the result straight into your stylesheet. No sign-up required.

Linear Radial Conic Live Preview 100% Free

Quick Presets

°
Your Gradient
/* Generated background */
background: linear-gradient(215deg, #ff7e5f, #feb47b, #86a8e7);

Tip: Click on previous swatches to quickly reapply them

Why You Are Here

Gradients are easy to write and hard to write well. The syntax takes thirty seconds to learn, but the difference between a gradient that looks polished and one that looks amateur comes down to details that are difficult to judge without seeing the result: the angle, where the color stops sit, and whether the two colors you picked produce a muddy band through the middle.

That is the real reason a visual generator matters. You are not here because you cannot remember linear-gradient(). You are here because you want to see the gradient while you adjust it.

The first situation is building a background or hero section. You need something more interesting than a flat color but you do not want to load an image file. A gradient gives you visual depth in around a hundred bytes of CSS that scales to any screen size without going blurry.

The second is matching a design spec. A designer handed you a Figma file with a gradient in it, and you need to reproduce the angle and stop positions accurately in CSS rather than approximating by eye.

The third is exploring. You know roughly what you want, warm and energetic or cool and calm, but you need to try twenty combinations quickly to find the one that works with the rest of your interface.

What This Tool Does

The CSS Gradient Generator gives you visual controls for building a gradient and outputs the CSS as you work.

Choose your gradient type: linear for a straight-line transition, radial for a circular or elliptical spread from a center point, or conic for a sweep rotating around a center.

Set your colors and stop positions, adjust the angle or center position, and watch the preview update in real time.

Copy the generated background value and paste it into your stylesheet.

Everything runs in your browser. Nothing is uploaded or stored.

The Three Gradient Types

Linear gradient

Transitions colors along a straight line at whatever angle you specify. This is the workhorse: hero backgrounds, button fills, section dividers, progress bars, and image overlays.

background: linear-gradient(90deg, #8B5CF6, #EC4899);

Radial gradient

Transitions outward from a center point in a circle or ellipse. Use it for glows, spotlight effects, soft vignettes, and anything that should draw the eye toward a focal point.

background: radial-gradient(circle at center, #A18CD1, #FBC2EB);

Conic gradient

Sweeps colors around a center point like the hand of a clock. Reach for it when you need pie charts, color wheels, loading spinners, or angular decorative effects.

background: conic-gradient(from 0deg, #FF6B6B, #FECA57, #48DBFB, #FF6B6B);
Each of the three also has a repeating variant: repeating-linear-gradient(), repeating-radial-gradient(), and repeating-conic-gradient(). These tile the gradient infinitely and are how CSS-only stripe, checkerboard, and starburst patterns get made.

Gradient Angle Reference

CSS gradient angles are a common source of confusion because they do not work the way most rotation systems do. In CSS, 0deg points UP, and the angle increases CLOCKWISE.

Angle Keyword Equivalent Direction of Transition

0deg

to top

Bottom to top

45deg

Bottom-left to top-right

90deg

to right

Left to right

135deg

Top-left to bottom-right

180deg

to bottom

Top to bottom

225deg

Top-right to bottom-left

270deg

to left

Right to left

315deg

Bottom-right to top-left

IMPORTANT SUBTLETY: to top right, to bottom right, and the other corner keywords are NOT fixed angle equivalents. They adjust to the element's aspect ratio so the gradient line runs perpendicular to the box's diagonal. On a perfect square, to bottom right matches 135deg. On a wide banner, it does not. If you need an exact angle regardless of element size, use degrees rather than corner keywords.

Color Stop Positioning

By default, colors distribute evenly. Two colors sit at 0% and 100%; three colors sit at 0%, 50%, and 100%. You override that by adding a position after any color.

Technique Syntax Result

Even distribution

linear-gradient(red, blue)

Smooth 0% to 100% blend

Explicit positions

linear-gradient(red 20%, blue 80%)

Solid red to 20%, solid blue from 80%

Hard stop

linear-gradient(red 50%, blue 50%)

Sharp line, no blending

Double position

linear-gradient(red 0% 50%, blue 50% 100%)

Same hard stop, shorter syntax

Midpoint hint

linear-gradient(red, 30%, blue)

Shifts the blend midpoint to 30%

Transparent fade

linear-gradient(#000, transparent)

Fades to nothing

The midpoint hint is worth knowing. A bare percentage between two colors, with no color attached to it, moves the point at which the two colors are evenly mixed. It is the simplest way to make a gradient feel weighted toward one end without adding a third color.

Practical Gradient Recipes

These are the patterns developers actually search for, with the complete CSS each one needs.

Text with a gradient fill

.gradient-text {
  background: linear-gradient(90deg, #8B5CF6, #EC4899);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* All four properties are required. Without color: transparent
   the text covers the gradient, and the -webkit- prefix is
   still needed for Safari. */

Gradient border

.gradient-border {
  border: 4px solid transparent;
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(90deg, #8B5CF6, #EC4899) border-box;
}

/* There is no border-gradient property in CSS. The trick is
   layering two backgrounds and clipping one to the padding box
   and one to the border box. */

Readable text over an image

.hero {
  background:
    linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)),
    url('hero.jpg') center / cover;
}

/* A flat semi-transparent gradient layered over the image
   darkens it uniformly so white text stays legible. */

Animated gradient background

.animated {
  background: linear-gradient(270deg, #8B5CF6, #EC4899, #3B82F6);
  background-size: 600% 600%;
  animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

/* Gradients cannot be transitioned directly because a gradient
   is an image, not a color. Oversize the background and animate
   its position instead. */

Fade-out edge

.fade-bottom {
  mask-image: linear-gradient(to bottom, #000 70%, transparent);
}

/* Using a gradient as a mask fades an element out rather than
   laying a color over it, which works over any background. */

Gradient Use Case Reference

Element Gradient Type Typical Approach

Hero background

Linear

Two or three colors, 135deg diagonal

Button fill

Linear

Two close colors, 90deg or 180deg

Card hover effect

Linear

Subtle shift, animated background position

Image overlay

Linear

Semi-transparent black or brand color

Glow or spotlight

Radial

Bright center fading to transparent

Vignette

Radial

Transparent center to dark edges

Pie chart

Conic

Hard stops at each segment boundary

Loading spinner

Conic

Color to transparent sweep

Stripes

Repeating linear

Hard stops at regular intervals

Progress bar

Linear

Brand color range, 90deg

Understanding Color Banding

Banding is the visible stepping you sometimes see across a gradient instead of a smooth blend: faint stripes running perpendicular to the gradient direction. It shows up most on large areas, on gradients between similar colors, and on displays with limited color depth.

It happens because the screen has a finite number of colors available. Spread a subtle transition across two thousand pixels and there are not enough distinct values to fill every step, so the browser repeats values and you see the seams.

Fix How It Helps

Add intermediate color stops

Gives the browser more anchor points and shortens each interpolated run

Increase contrast between colors

Banding is worst on low-contrast gradients because there are few distinct values between endpoints

Overlay very subtle noise

A faint noise texture at low opacity breaks up the bands visually (dithering)

Interpolate in a perceptual space

Produces more even transitions and avoids the muddy gray zone in default sRGB blending

background: linear-gradient(in oklab, #FF6B6B, #4ECDC4);

/* Browser support for this syntax is good in current versions
   but not universal. Provide a standard gradient as a fallback
   declaration before it if you support older browsers. */

Common Mistakes to Avoid

Assuming 0deg Points Right

Most rotation systems, including CSS transform: rotate(), treat 0 degrees as pointing right. CSS gradients do not. In a gradient, 0deg points to the top and the angle increases clockwise, so 90deg points right and 180deg points down. A developer who assumes 0deg is horizontal will consistently get gradients rotated 90 degrees from what they intended. When in doubt, use the keyword form: to right is unambiguous.
Trying to Transition or Animate a Gradient Directly

Writing transition: background 0.3s on an element whose background is a gradient does nothing, because a gradient is an image rather than a color, and CSS cannot interpolate between two images. The gradient will snap instantly instead of easing. Animate background-position on an oversized gradient, or animate opacity on a second layered element holding the target gradient.
Placing Text on a Gradient Without Checking Contrast at Both Ends

A gradient means the background color behind your text changes across the element. Text that meets the WCAG 4.5 to 1 contrast ratio against the light end of a gradient may fail badly against the dark end. Check the contrast of your text color against the lightest and darkest points of the gradient, not just against one end or an average. If it fails at either extreme, add a semi-transparent overlay or constrain the gradient's lightness range.

Quick Reference

Item Value

0deg

to top

90deg

to right

180deg

to bottom

270deg

to left

Linear

Straight line

Radial

From a center point

Conic

Sweep around a center

Hard stop

Same position twice

Gradient text

background-clip: text

Animate

background-position

Frequently Asked Questions

What is a CSS gradient generator?

A CSS gradient generator is a free online tool that lets you build a gradient visually and copy the resulting CSS code. Instead of writing linear-gradient() by hand and reloading to check the result, you adjust colors, angles, and stop positions with live controls and see the gradient update instantly. This CSS Gradient Generator supports linear, radial, and conic gradients.

What is the difference between linear, radial, and conic gradients?

A linear gradient transitions colors along a straight line at a given angle, which suits backgrounds, buttons, and overlays. A radial gradient radiates outward from a center point in a circle or ellipse, which suits glows and spotlight effects. A conic gradient sweeps colors around a center point like a clock hand, which suits pie charts, color wheels, and spinners.

How do CSS gradient angles work?

In CSS gradients, 0deg points to the top and angles increase clockwise. So 90deg goes left to right, 180deg goes top to bottom, and 270deg goes right to left. These map to the keywords to top, to right, to bottom, and to left. Note that corner keywords like to bottom right adapt to the element's aspect ratio rather than locking to a fixed angle.

How do I make gradient text in CSS?

Apply the gradient as a background, clip that background to the text with background-clip: text plus the -webkit- prefixed version for Safari, then set color: transparent so the text itself does not cover the gradient. All four declarations are required for the effect to work.

Why does my gradient look striped instead of smooth?

That striping is called color banding, and it happens when there are not enough distinct color values available to fill a long, subtle transition, so the browser repeats values and the steps become visible. Adding intermediate color stops, increasing the contrast between your colors, overlaying faint noise, or interpolating in a perceptual color space such as oklab all reduce it.

Can I animate a CSS gradient?

Not directly. A gradient is an image rather than a color value, so CSS cannot transition between two gradients. The standard workaround is to make the gradient much larger than its container with background-size and animate background-position, which slides the gradient across the element and reads as a smooth color shift.

Do CSS gradients need vendor prefixes?

Not for modern projects. Unprefixed linear-gradient(), radial-gradient(), and conic-gradient() are supported across all current browsers. The -webkit- prefix is still required in one specific case: background-clip: text for gradient text effects in Safari. Otherwise the plain syntax is sufficient.

Are gradients better than background images?

For solid color transitions, generally yes. A gradient is typically a hundred to two hundred bytes of CSS against several kilobytes for an equivalent image, it needs no extra HTTP request, it scales to any container size without becoming blurry or pixelated, and you can change its colors by editing one line. Use images when you need photographic detail or texture that gradients cannot produce. Use this CSS Gradient Generator when a color transition is all you need.

Comments

Login to leave a comment

No comments yet. Be the first to comment!