Radial and Conic Gradients: Understanding the Mechanics

CSS gradients are a versatile tool for creating visual effects without extra HTML elements. Two of the most powerful gradient functions are radial-gradient() and conic-gradient(). While they may look similar at first glance, they work quite differently: radial gradients emanate from a center point along straight lines, while conic gradients rotate around a central axis. Understanding these differences is key to using them effectively.

How Radial Gradients Behave

The simplest radial gradient uses just two color stops. In this case, the browser renders an ellipse that fills the container's width and height.

.element {
    background: radial-gradient(#9c27b0, #ff9800);
}
Radial-gradient
(Large preview)

The default shape is an ellipse unless you specify otherwise. This happens when no explicit shape keyword is given or when two size values (width and height) are provided. The color transitions are computed as starting at 0% and ending at 100%, creating a smooth blur from the center outward.

.element {
    background: radial-gradient(#9c27b0, #ff9800);
}
Ellipse-shaped gradient
(Large preview)
.element {
    background: radial-gradient(#9c27b0 0%, #ff9800 100%);
}

Controlling Shape and Position

Adding the circle keyword before the first color stop forces a perfect circle instead. Both circles and ellipses are centered at 50% 50% of the container by default.

.element {
    background: radial-gradient(circle, #9c27b0, #ff9800);
}
Circle-shaped gradient
(Large preview)
Ellipse and circle elements centered horizontally and vertically in their container
(Large preview)

Positioning works from the center of the shape, not its edges. So when you position a circle at the top left, it's the center point of that circle that gets placed there.

.element {
    background: radial-gradient(circle at top left, #9c27b0, #ff9800);
}
Radial-gradient with circle at top left
(Large preview)
.element {
    background: radial-gradient(circle at right, #9c27b0, #ff9800);
}
Radial-gradient with circle at right
(Large preview)

How Conic Gradients Work

Unlike radial gradients, conic gradients rotate around the center of the element in a full circle. By default, the sweep goes from 0deg to 360deg.

.element {
    background: conic-gradient(#9c27b0, #ff9800);
}
Conic-gradient
(Large preview)

The key insight with conic gradients is how you control the color stops. A hard stop value for the first color (for example, 50%) makes that color fill half the element, while the next color gradually blends in from that point to the end. Applying hard stops to all colors creates distinct segment boundaries.

.element {
    background: conic-gradient(#9c27b0 50%, #ff9800);
}
Conic-gradient where the first color fills 50% of the element, the second one is gradually shown till 100%
(Large preview)
.element {
    background: conic-gradient(#9c27b0 50%, #ff9800 0);
}
Conic-gradient where the first color fills 50% of the element, and the second one starts from 50% to the end
(Large preview)

Varying the color stop values changes the shape of the transitions. Increasing the first stop value, for example, creates a sharper angled fill rather than a smooth gradient.

.element {
    background: conic-gradient(#9c27b0 65%, #ff9800 0);
}
The first color stop is increased up to 65% which forms an angled fill
(Large preview)

For repeating patterns, the repeating-conic-gradient() function provides the same capability as its radial counterpart. It allows you to define a segment that repeats around the circle, as shown when one color fills from 0deg to 15deg and a second from 15deg to 30deg, then the pattern loops.

.element {
    background: repeating-conic-gradient(
    #9c27b0 0 15deg,
    #ff9800 15deg 30deg
    );
}
Repeating-conic-gradient
(Large preview)

Practical Uses for Radial Gradients

Radial gradients excel at drawing attention to content or creating textures. A common use case is in hero sections where a busy background image could interfere with readability.

Improving Content Readability

When a headline or secondary text is placed over a complex illustration, an ellipse gradient using the background's color can help isolate the content. This creates a smoother transition from the text area to the surrounding pattern, making it easier for the reader to focus.

An example of a use case where the content is overlapped with the background
(Large preview)
The hero section with the ellipse colored in grey
(Large preview)
.hero {
    background-color: #fbfafa;
    background-image: radial-gradient(#fbfafa, rgba(0,0,0,0) center/70% 70% no-repeat, url("hero-bg.svg");
    background-position: center;
    background-size: 70% 70%, cover;
    background-repeat: no-repeat;
}
And example of a use case where the content isn't overlapped with the background anymore, due to the added ellipse with the same color as the background underneath
(Large preview)

Dotted Pattern Generation

By defining a small circle and leaving the rest transparent, you can create a dotted pattern. Since gradients tile by default, a properly sized gradient will repeat seamlessly. The trick is to specify the gradient's width and height so the pattern tiles as expected.

Dotted pattern
(Large preview)
Circle color and the rest of the gradient is transparent color.
(Large preview)
A repeated pattern with a cirlce color and the rest of the gradient is transparent color
(Large preview)
.dot-pattern {
  --color-1: #9c27b0;
  --color-2: rgba(0,0,0,0);
  background-image: radial-gradient(circle at 2px 2px, var(--color-1) 1px, var(--color-2) 0);
  background-size: 15px 15px;
}

Blending With Images

Pairing a radial gradient with mix-blend-mode opens up creative possibilities for image effects. Positioning the gradient in a specific corner, for instance, lets you control where the blend effect appears.

An example where radial gradient creates an interesting UI effect for an image. Namely, the circle is positioned at the top-left corner of the image which creates a gradient
(Large preview)
.thumb:after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top left, #9c27b0, #ff9800);
    mix-blend-mode: hard-light;
    opacity: 0.4;
}

Conic Gradients in Real Interfaces

Conic gradients shine in scenarios where you need circular progress or angular segmentation. Their ability to rotate smoothly around a center point makes them ideal for several distinct UI patterns.

Building Pie Charts

Creating a simple pie chart has become trivial with conic gradients, fulfilling a long-standing CSS request. You can divide the circle into segments by applying hard color stops at appropriate angles, with no need for SVG or canvas.

Pie chart
A simple pie chart (Large preview)
.pie-chart {
    width: 100px;
    height: 100px;
    background: conic-gradient(from 0deg, #b2daf9 128deg, #2096f3 0);
    border-radius: 50%;
}

Creating Checkerboard and Angular Patterns

Patterns are another strong area for conic gradients. A checkerboard effect is achievable by specifying four color segments of 90deg each, then controlling the repetition with background-size. Rotating the angle values within the pattern produces variations that resemble different woven or tiled textures.

Checkerboard pattern
A 2×2 checkerboard pattern achieved with conic-gradient(). (Large preview)
.checkerboard {
    --size: 25px;
    width: 200px;
    height: 100px;
    background-image: conic-gradient(#fff 90deg, #000 0 180deg, #fff 0 270deg, #000 0);
    background-size: var(--size) var(--size);
}
A repeated checkerboard pattern
A preview of the checkerboard pattern that has been repeated several times. (Large preview)
.element {
    background-image: conic-gradient(#fff 90deg, #000 0 136deg, #fff 0 313deg, #000 0);
}
A rotated repeated checkerboard pattern
Same checkboard pattern, but different. (Large preview)

Generating Random UI Patterns

You can create unpredictable-looking shapes by combining conic gradients with small background tiles. For an element with a set width and height, setting background-size to repeated tiles allows each tile to contain its own gradient. Making one of the stop colors transparent turns the gradient into a triangle. Changing the gradient angle on different tiles produces varied and interesting composite effects.

.element {
    --size: 20px;
    width: 200px;
    height: 200px;
    background-size: var(--size) var(--size);
}
An element with a width and height of 200px, and within this element there is a repeated background which has a size of 20px
An element (200×200px) which has a repeated background with a size of 20px. (Large preview)
.element {
    --size: 20px;
    width: 200px;
    height: 200px;
    background: conic-gradient(#2296F3 0.13turn, rgba(255,255,255,0) 0);
    background-size: var(--size) var(--size);
}
Two squares with blue conic gradients in a triangle shape. The first square has a dark-blue background, and the second square has a transparent one
(Large preview)
An element with a repeated background with triangle shapes
(Large preview)
Different pattern shapes which are formed by different angles: 0,08 turn, 0,03 turn and 0,5turn
(Large preview)

Animating With the @property Rule

Animating conic gradients requires registering a custom property via the @property rule. This notifies the browser that the property is animatable, allowing smooth transitions between gradient states that would otherwise fail to interpolate.

@property --conic-mask {
    syntax: '<percentage>';
    inherits: false;
    initial-value: 0%;
}

.conic-mask {
    --conic-mask: 0%;
    -webkit-mask: conic-gradient(from 0deg at 50% 50%, #000 var(--conic-mask), #0000);
    transition: --conic-mask 1s ease-out;
}

.conic-mask: hover {
    --conic-mask: 100%;
}
An animation effect with conic-gradient.

Custom Masks for Cut Corners

Conic gradients also work well as mask layers. One demonstrated technique uses a conic gradient in a mask to create cut-corner effects on elements, simulating a style normally handled by clip-path or SVG shapes.

See the Pen [Cut corners with custom shape [forked]](https://codepen.io/smashingmag/pen/jOGKjxQ) by Temani Afif.

See the Pen Cut corners with custom shape [forked] by Temani Afif.

Subtle Color Effects

Several small libraries and demos show how conic gradients give subtle color variety to UI elements. This can mean producing corners that are slightly darker or lighter in tone, giving surfaces a more dimensional feel with minimal code.

Conic gradients with different colors
(Large preview)

Section Backgrounds With Smooth Transitions

A notable pattern uses a conic gradient to add color to a page section, like a footer, making it appear as if the color is partially wrapping around the content in a smooth, elegant way.

.footer {
    background: conic-gradient(from 0.25turn at 25% 0%, #FFD9CE, rgba(#FFD9CE, 0) 50%);
}
Typetura footer with conic gradient
(Large preview)

The choice between radial and conic gradients isn't always clear-cut. Radial gradients are ideal for fading outward from a focal point, while conic gradients are built for angular sweeps and segmentation. In practice, the specific design need dictates which function to use.

Smashing Editorial