CSS Gradients: A Complete Guide to linear-gradient, radial-gradient, and conic-gradient

●2 ●92 ●140
calendar_today • schedule2 min read

CSS gradients let you create smooth colour transitions entirely in the browser — no images, no SVGs, no external dependencies. The syntax trips people up at first, but once you understand the model, you can build backgrounds, borders, buttons, and decorative effects that would have required a designer and a Photoshop export a decade ago.

This guide covers all three gradient types with working examples you can drop straight into your CSS.

linear-gradient — Straight-line transitions

The most common gradient. Colours transition along a straight line from one edge to another.

/* Basic: top to bottom */
background: linear-gradient(to bottom, #2f855a, #276749);

/* Angled: diagonal */
background: linear-gradient(135deg, #667eea, #764ba2);

/* Three stops */
background: linear-gradient(to right, #f6d365, #fda085, #f093fb);

Direction syntax

There are two ways to specify direction:

/* Keyword — clear intent */
linear-gradient(to right, ...)        /* left → right */
linear-gradient(to bottom right, ...) /* top-left → bottom-right */

/* Angle — precise control */
linear-gradient(0deg, ...)   /* bottom → top */
linear-gradient(90deg, ...)  /* left → right */
linear-gradient(45deg, ...)  /* diagonal */

The default (no direction specified) is to bottom — top to bottom.

Colour stops and positions

/* Default: colours spaced evenly */
linear-gradient(to right, red, blue);

/* Explicit positions */
linear-gradient(to right, red 0%, blue 100%);

/* Abrupt change (hard stop) — the same position twice */
linear-gradient(to right, red 50%, blue 50%);

/* Uneven spacing */
linear-gradient(to right, red 20%, yellow 40%, green 80%);

Repeating linear gradients

/* Candy stripe */
background: repeating-linear-gradient(
  45deg,
  transparent,
  transparent 10px,
  #2f855a 10px,
  #2f855a 20px
);

radial-gradient — Circular and elliptical transitions

Colours radiate outward from a centre point.

/* Circle from centre */
background: radial-gradient(circle, #667eea, #764ba2);

/* Ellipse (default shape) */
background: radial-gradient(ellipse, #f6d365, #fda085);

/* Positioned */
background: radial-gradient(circle at top left, #2f855a, transparent);

Size keywords

/* closest-side — gradient fits to nearest edge */
background: radial-gradient(circle closest-side at 20% 50%, #667eea, transparent);

/* farthest-corner (default) — gradient reaches farthest corner */
background: radial-gradient(circle farthest-corner at 20% 50%, #667eea, transparent);

Practical use: spotlight effect

.hero {
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(102,126,234,0.4), transparent),
    #1a202c;
}

conic-gradient — Pie chart and colour wheel transitions

Colours rotate around a centre point like a colour wheel or pie chart. Browser support is solid (Chrome 69+, Firefox 83+, Safari 12.1+).

/* Basic pie */
background: conic-gradient(#f6d365 0% 33%, #fda085 33% 66%, #f093fb 66% 100%);

/* Colour wheel */
background: conic-gradient(
  hsl(0, 100%, 50%),
  hsl(60, 100%, 50%),
  hsl(120, 100%, 50%),
  hsl(180, 100%, 50%),
  hsl(240, 100%, 50%),
  hsl(300, 100%, 50%),
  hsl(360, 100%, 50%)
);

/* Rotated start position */
background: conic-gradient(from 90deg, #667eea, #764ba2);

/* Positioned centre */
background: conic-gradient(from 0deg at 30% 50%, #f6d365, #fda085);

Layering Multiple Gradients

background accepts a comma-separated list. Gradients are layered front-to-back:

background:
  linear-gradient(to right, rgba(255,255,255,0) 50%, rgba(255,255,255,0.1) 100%),
  linear-gradient(135deg, #667eea 0%, #764ba2 100%);

This is how you create glossy buttons, depth effects, and layered backgrounds without images.

Common Patterns

Frosted card background

.card {
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0));
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.18);
}

Gradient border (using background-clip)

.btn {
  border: 2px solid transparent;
  background:
    linear-gradient(white, white) padding-box,
    linear-gradient(135deg, #667eea, #764ba2) border-box;
}

Subtle section divider

.section-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, #e2e8f0 20%, #e2e8f0 80%, transparent);
}

Building Gradients Without Trial and Error

Writing gradient CSS by hand is possible but slow — getting the angle, stop positions, and colour values right takes iteration. A visual gradient builder is much faster. SnappyTools has a free CSS gradient generator that lets you drag stops, pick colours, and copy the ready-to-paste CSS — no signup needed.

Quick Reference

TypeSyntaxUse case
linear-gradientlinear-gradient(direction, color stops)Backgrounds, buttons, dividers
radial-gradientradial-gradient(shape size at position, color stops)Glows, spotlights, vignettes
conic-gradientconic-gradient(from angle at position, color stops)Pie charts, colour wheels, spinners
repeating-*Same as above, tiledStripes, patterns, textures

Gradients are one of those CSS features where a small amount of knowledge unlocks a disproportionately large amount of design capability. Start with linear-gradient, learn the stop syntax, then reach for radial and conic when you need circular or rotational effects.

Originally published at https://snappytools.app/gradient-generator/

Want more #webdev & #frontend deep dives?

Join 6,173+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

More Posts

How I Built a React Portfolio in 7 Days That Landed ₹1.2L in Freelance Work

Dharanidharan - Feb 9

Sovereign Intelligence: The Complete 25,000 Word Blueprint (Download)

Pocket Portfolio - Apr 1

I’m a Senior Dev and I’ve Forgotten How to Think Without a Prompt

Karol Modelski - Mar 19

CSS Gradient Generator: A Complete Reference for Linear, Radial, and Conic Gradients

SnappyTools - Jun 1

CSS Gradients: Linear, Radial, and Conic — Syntax Reference and Real Examples

SnappyTools - Jun 11
chevron_left
2.5k Points • 234 Badges
102Posts
0Comments
SnappyTools builds free, fast, browser-based tools for developers, writers, and designers. No signup... Show more

Related Jobs

View all jobs →

Commenters (This Week)

18 comments
5 comments

Contribute meaningful comments to climb the leaderboard and earn badges!