Learn

Linear vs Radial vs Conic — When to Use What

Each CSS gradient type has strengths that make it the right choice for specific UI patterns. Here's how to pick the right one.

Linear gradients

A linear gradient transitions colors along a straight axis, defined by an angle or direction keyword.

/* Angle in degrees */
background: linear-gradient(135deg, #6366f1, #a855f7);

/* Direction keywords */
background: linear-gradient(to right, #6366f1, #a855f7);
background: linear-gradient(to bottom right, #6366f1, #a855f7);

Best for:

  • Hero backgrounds and full-page gradients — the diagonal feel adds movement and energy.
  • Buttons and interactive elements — a top-to-bottom gradient mimics a light source and gives a raised look.
  • Data visualization color scales — horizontal gradients are intuitive for sequential data.
  • Text fills — background-clip: text works well with linear gradients.

Common angles:

  • 0deg / to top — bottom to top
  • 90deg / to right — left to right
  • 135deg — diagonal (top-left to bottom-right) — the most common "energy" angle
  • 180deg / to bottom — top to bottom (good for scrims)

Radial gradients

A radial gradient radiates outward from a center point in a circular or elliptical shape.

/* Circle (same radius in all directions) */
background: radial-gradient(circle, #f97316, #1e1b4b);

/* Ellipse (default — stretches with element) */
background: radial-gradient(ellipse, #f97316, #1e1b4b);

/* Custom position */
background: radial-gradient(circle at 30% 70%, #f97316, #1e1b4b);

/* Custom size */
background: radial-gradient(circle 200px at center, #f97316, #1e1b4b);

Best for:

  • Spotlight / glow effects — a radial gradient from a bright center gives a realistic light falloff.
  • Vignettes — dark edges fading to a lighter center (or vice versa).
  • Circular UI elements like avatars, badges, or clock faces.
  • Depth effects — a centered gradient on a card makes it look three-dimensional.

Tips:

  • circle gives a circular gradient regardless of element aspect ratio.ellipse (default) stretches to fit the element — useful for full-bleed backgrounds.
  • Move the center with at X Y to simulate an off-center light source.

Conic gradients

A conic gradient sweeps colors around a center point, like a color wheel or pie chart. Colors are distributed by angle, not distance.

/* Basic conic */
background: conic-gradient(red, yellow, green, blue, red);

/* From a specific starting angle */
background: conic-gradient(from 45deg, #ff6b35, #6366f1);

/* Pie chart (hard stops) */
background: conic-gradient(
  #e63946 0% 40%,
  #457b9d 40% 75%,
  #2a9d8f 75% 100%
);

Best for:

  • Pie and donut charts — conic gradients are the native CSS way to draw pie slices.
  • Color wheel backgrounds — decorative rainbow rings or angle-based color pickers.
  • Spinners and loaders — a conic gradient combined with rotation creates smooth progress indicators.
  • Angular highlight effects — a sweeping shine on a metallic or glass surface.

Tips:

  • Use hard stops (two consecutive stops at the same position) to create crisp boundaries between sections.
  • Combine with border-radius: 50% to mask to a circle for pie charts.
  • Conic gradients are newer — verify browser support if targeting older environments.

Repeating variants

All three types have a repeating- prefix that tiles the gradient pattern:

/* Striped background */
background: repeating-linear-gradient(
  45deg,
  transparent,
  transparent 10px,
  rgba(0,0,0,0.1) 10px,
  rgba(0,0,0,0.1) 20px
);

/* Circular rings */
background: repeating-radial-gradient(circle, #fff 0px, #fff 5px, #eee 5px, #eee 10px);

Repeating gradients are great for textures (hatching, dashed lines, checkerboards) without image assets.

Quick decision guide

  • Directional flow (top-to-bottom, diagonal) → linear
  • Light source / glow / vignette → radial
  • Pie chart / color wheel / sweep → conic
  • Texture / pattern / stripes → repeating-linear or repeating-radial