๐Ÿ“š Colour & design ยท Guide

How to Create CSS Gradients: Linear, Radial and Conic (With Examples)

Design linear, radial and conic CSS gradients with up to five colour stops and copy the ready CSS. Learn the syntax, angles, colour stops, hard edges and how to keep text readable on gradients.

By RexBD Team 24 Nov 2026 7 min read 1,505 words
How to Create CSS Gradients: Linear, Radial and Conic (With Examples)

Gradients are one of the easiest ways to make a website feel modern and polished. A subtle gradient can give a flat button depth, a bold one can make a hero section stand out, and a conic gradient can draw a pie chart or a colour wheel without a single image file. Because they are pure CSS, gradients load instantly, scale to any screen size and are easy to change.

Writing gradient code by hand is fiddly, though: angles, colour stops, positions and shapes. The free CSS Gradient Generator on RexBD lets you design linear, radial and conic gradients visually with up to five colour stops, and copy ready-to-use CSS. This guide shows how to use it and explains the syntax so you can tweak the result confidently.

The three types of CSS gradient

Linear gradients

Colours blend along a straight line:

background: linear-gradient(135deg, #22d3ee, #6366f1);

The angle sets the direction. 0deg goes from bottom to top, 90deg from left to right, 180deg from top to bottom, and 135deg diagonally from the top left to the bottom right. You can also use keywords such as to right or to bottom left.

Radial gradients

Colours spread out from a centre point, as a circle or an ellipse:

background: radial-gradient(circle at 30% 30%, #fde68a, #f97316);

Radial gradients are great for soft spotlights, glows and making a section feel lit from one side.

Conic gradients

Colours rotate around a centre point, like the hands of a clock:

background: conic-gradient(from 0deg, #ef4444, #eab308, #22c55e, #3b82f6, #ef4444);

Conic gradients are perfect for colour wheels, pie charts and loading indicators. All modern browsers support them.

๐ŸŒ… Free tool ยท no sign-upTry the CSS Gradient GeneratorDesign linear, radial and conic CSS gradients with up to five colour stops and copy the ready CSS. Open tool โ†’

How to use the CSS Gradient Generator

Step 1: Choose the gradient type

Open the CSS Gradient Generator and choose linear, radial or conic.

Step 2: Pick your colours

Add up to five colour stops. Click each stop to change its colour. Use your brand colours, or get ideas from the Colour Palette Generator.

Step 3: Adjust positions and direction

Move the stops to control where each colour starts and ends. For linear gradients, set the angle. For radial and conic gradients, set the shape or centre.

Step 4: Preview

See the gradient update live as you change settings.

Step 5: Copy the CSS

Copy the generated CSS and paste it into your stylesheet. Everything runs in your browser.

Colour stops explained

Each colour in a gradient can have a position:

background: linear-gradient(90deg, #0ea5e9 0%, #8b5cf6 50%, #ec4899 100%);
  • Without positions, colours are spaced evenly.
  • With positions, you control exactly where each colour sits.

Hard edges and stripes

If two stops share the same position, the colour changes instantly instead of blending, creating a sharp edge:

background: linear-gradient(90deg, #111827 50%, #f59e0b 50%);

That gives a split background, half dark and half amber. Repeating gradients build stripes:

background: repeating-linear-gradient(45deg, #e5e7eb 0 10px, #f9fafb 10px 20px);

For more complex patterns, try the CSS Pattern Generator.

Ad Kothay

Design tips for beautiful gradients

  1. Choose colours that sit near each other on the colour wheel for smooth, natural gradients, such as blue to purple, or orange to pink.
  2. Avoid muddy middles. Blending complementary colours, such as red to green, can produce a dull grey or brown in the middle. Add a bright middle stop to keep it vivid.
  3. Keep subtle gradients subtle. For backgrounds and buttons, a small change in lightness looks elegant. Big, saturated gradients work for hero sections and posters.
  4. Use angles purposefully. Diagonal gradients feel dynamic; vertical gradients feel calm and natural, like the sky.
  5. Limit the number of colours. Two or three stops usually look better than five.
  6. Reuse the same gradient across your site for a consistent brand look.

Keeping text readable on gradients

Text over a gradient can be easy to read at one end and hard at the other. To keep it accessible:

  • Check the contrast between your text colour and both ends of the gradient with the Contrast Checker. WCAG recommends at least 4.5:1 for normal text.
  • Add a semi-transparent dark or light overlay behind text if needed.
  • Keep important text over the part of the gradient with the best contrast.
  • Set a solid background-color fallback before the gradient, so text stays readable if the gradient fails to load in an unusual environment.

Useful gradient techniques

Gradient overlay on an image

Darken the bottom of a photo so white text on top is readable:

background: linear-gradient(to bottom, rgba(0,0,0,0) 40%, rgba(0,0,0,.7)), url(photo.jpg) center/cover;

Gradient text

background: linear-gradient(90deg, #22d3ee, #a855f7);
-webkit-background-clip: text;
background-clip: text;
color: transparent;

Use it for short headings only, and check that it remains readable.

Gradient borders

A common trick is to place a gradient background on an outer element with padding and a solid background on an inner element, so the gradient shows as a border. Rounded corners can be set with the Border Radius Generator.

Soft glows with radial gradients

Several transparent radial gradients layered on a dark background create the glowing "aurora" look popular in modern landing pages. Combine with the Glassmorphism Generator for frosted-glass cards.

A worked example: a landing page hero

A start-up wants a bold but readable hero section. The designer opens the generator and creates a linear gradient at 135 degrees from deep indigo (#312e81) to violet (#7c3aed), with a third stop of hot pink (#db2777) at 100%. It looks vibrant, but white text over the pink end is slightly hard to read.

She checks contrast: white on indigo passes easily, white on pink is borderline for small text. She moves the pink stop to 120% so less pink appears in the visible area, and places the headline on the left, over the darker part. Contrast now passes comfortably everywhere the text sits. She copies the CSS, adds a solid indigo background-color as a fallback, and reuses the same gradient for the main buttons. The result is a consistent, eye-catching brand look made entirely in CSS.

Gradient ideas for common interface elements

Element Gradient idea Why it works
Primary button Two close shades of the brand colour, top to bottom Adds subtle depth without distraction
Hero section Diagonal blend of two brand colours Creates energy and draws attention
Card background Very faint gradient from white to off-white Separates cards from the page gently
Progress bar Left-to-right blend from one colour to another Suggests movement and completion
Image overlay Transparent to dark, top to bottom Makes text over photos readable
Section divider Hard-edged gradient or angled stripe Adds visual rhythm between sections
Avatar placeholder Radial gradient using the user's colour Looks friendly before a photo loads

Gradients and colour formats

The generator outputs colours in HEX, which works everywhere. You can also write gradient colours in other formats in your own CSS:

  • RGBA or HSLA for transparency, such as rgba(0, 0, 0, 0.5). Transparent stops are essential for overlays.
  • HSL makes it easy to create smooth gradients by changing only the hue or the lightness.
  • Modern colour spaces such as OKLCH are supported in recent browsers and can produce smoother, more even blends, especially between very different hues.

The Colour Converter switches between HEX, RGB and HSL if you want to fine-tune values by hand.

Performance and compatibility

CSS gradients are drawn by the browser, so they add no image downloads and stay sharp on high-resolution screens. Linear and radial gradients have been supported in all major browsers for over a decade, and conic gradients in all modern browsers. Very large, heavily layered gradients can cost a little rendering time on low-end phones, especially if animated, so keep animations of gradients modest.

Our CSS gradient tips and mistakes article has more ideas for design systems.

Frequently asked questions

How do I make a diagonal gradient in CSS?

Use an angle such as linear-gradient(135deg, colour1, colour2) or a keyword such as to bottom right.

How many colours can a gradient have?

CSS allows any number. The generator supports up to five stops, which covers nearly every design need.

How do I create a sharp line instead of a blend?

Give two neighbouring colour stops the same position.

Do gradients slow down my website?

No. They are drawn by the browser and need no image download. Only very complex animated gradients may affect performance on weak devices.

Can I use gradients on text?

Yes, with background-clip: text and a transparent text colour. Keep it to short headings and check readability.

Can I animate a CSS gradient?

Browsers cannot smoothly animate between two gradient values directly in all cases. A common trick is to make the gradient larger than the element and animate its background-position. Keep such animations slow and subtle.

Is the CSS Gradient Generator free?

Yes. It is free and runs in your browser.

Found this useful?Share it with a friend or colleague who needs it.

Keep reading

More colour & design articles
321 free tools, one placeSEO, text, images, code, money, units and design. Private, fast and almost all in your browser.
Ad Kothay