Skip to content
Tools

CSS Gradient Generator

Create and customize beautiful CSS gradients visually, then copy the generated CSS for your website or application. Everything runs locally in your browser.

Preview context

Create a gradient by choosing colors and adjusting the controls.

Click the bar to add a stop, drag a handle to move it, and use the arrow keys for one percent at a time — Shift for ten, Delete to remove.

CSS

background: linear-gradient(
  135deg,
  #4f46e5 0%,
  #06b6d4 100%
);
Settings panel
Gradient type

Travels in a straight line. The angle is the direction of travel: 0° points up and 90° points right, which is clockwise from north rather than the mathematical convention.

Direction

A keyword points at the side or corner whatever the box’s shape. A fixed angle does not, so the two only agree in a square.

The direction of travel. 0° points up and 90° points right — clockwise from north, not the mathematical convention.

Colour stops

Stop colour

HEX, RGB, RGBA, HSL, HSLA and the named colours. Alpha comes through.

This stop

  • hex#4F46E5
  • rgbrgb(79, 70, 229)
  • rgbargba(79, 70, 229, 1)
  • hslhsl(243, 75%, 59%)
  • hslahsla(243, 75%, 59%, 1)

Opacity

2 stopslinear49 characters

What is a CSS gradient?

A CSS gradient is a smooth transition between two or more colours, drawn by the browser rather than downloaded as a picture. It is a value for background-image, which means it has no resolution, no file size and no fixed dimensions — it is painted across whatever box it is applied to, at whatever size that box happens to be, and repainted when the box changes.

The whole idea, in one declaration
background: linear-gradient(135deg, #4f46e5, #06b6d4);

That single line replaces an exported image, its retina variant, the request that fetches it and the resolution decisions that go with it. It also stays sharp at any size, which no raster image does.

Every gradient is made of the same three parts: a kind that says how the colour travels, a geometry that says where, and a list of colour stops that says what. The rest of this page is those three things in detail.

What is a CSS gradient generator?

A visual editor for a syntax that is easy to read and awkward to write blind. Nothing about linear-gradient() is hard, but getting from a colour in your head to the right angle, the right stop percentages and the right notation is a loop of edit, save, look, adjust — and each pass costs a few seconds and some attention.

A generator collapses that loop. What it is actually buying you:

  • The angle problem disappears. CSS measures gradient angles clockwise from north, which is the opposite of the mathematical convention. Converting by hand is where gradients come out 90° off; dragging a dial is where they do not.
  • Stop positions become visible. Deciding that a colour belongs at 38% is a thing you do by eye, not by arithmetic.
  • Notation stops mattering. Paste a colour in any form — hex, rgb, hsl, a name — and it converts. Alpha comes through.
  • You see it where it will live. A gradient that looks striking across a hero can be unreadable behind a button, and the only way to know is to look at both.
  • Contrast gets checked.A gradient has a different contrast ratio at every point, so “is this accessible” is not a question anyone can answer by looking.

Everything on this page runs in your browser. No colour, gradient or export ever leaves the machine.

Types of CSS gradient

Three, and the difference between them is the shape of the line the colours are laid along.

Linear

The colours travel in a straight line across the box. The one you want nine times in ten: hero backgrounds, buttons, card headers, anything that wants a sense of direction.

Radial

The colours spread outwards from a point, in a circle or an ellipse. Good for a spotlight, a glow behind a subject, or a vignette. It has no angle — it has a shape, a size and a centre instead.

Conic

The colours sweep around a point like the face of a clock. This is how a pie chart gets drawn in one declaration, and how a colour wheel, a progress ring or a conical shine on a button gets made without an image.

All three have a repeating variant that tiles the stop sequence rather than holding the end colours, which is how stripes, checks and starbursts are made.

How to create a CSS gradient

  1. Pick the type. Linear for direction, radial for a glow, conic for a sweep. Switching between them here keeps every setting, so comparing costs nothing.
  2. Choose your colours. Click a stop and set it with the picker, or paste one in any notation. Two colours is a gradient; more than four usually reads as bands.
  3. Place the stops. Drag the handles on the bar, or type exact percentages. Click the bar to add a stop where you clicked.
  4. Set the geometry. An angle or a direction keyword for linear, a shape and centre for radial, a start angle for conic.
  5. Look at it in context. The preview switcher puts the same gradient behind a card, a button and text. The button is usually the one that catches a problem.
  6. Check the contrast if anything will sit on top of it. The Analysis tab shows the worst point rather than an average.
  7. Copy the form you need. A declaration, a custom property, SCSS, Tailwind or JSON — each is a different place the gradient ends up.

Linear gradient in CSS

A linear gradient travels along a line, and everything about it is a question of where that line points and what sits along it.

Direction and angle

Two ways to say the same thing, and they are not interchangeable. A keywordto right, to bottom left — points at that side or corner whatever shape the box is. An angle is fixed. In a square they agree; in a wide banner to bottom right follows the diagonal and 135deg does not.

Direction, three ways
background: linear-gradient(to right, #4f46e5, #06b6d4);background: linear-gradient(135deg, #4f46e5, #06b6d4);background: linear-gradient(#4f46e5, #06b6d4);  /* defaults to 'to bottom' */

The angle is measured clockwise from north. 0° points up, 90° points right, 180° points down. That is the opposite convention from mathematics, where angles run anticlockwise from east — and it is why gradients converted by hand so often come out exactly 90° wrong. The angle is the direction the gradient travels, not where it comes from.

Colour stops and position

Each stop names a colour and, optionally, where along the line it is at full strength. Leave the positions out and the browser spreads them evenly; write them and you control the pacing.

Three stops, placed
background: linear-gradient(  to right,  #4f46e5 0%,  #06b6d4 50%,  #22c55e 100%);

This tool always writes the positions out. An implicit position is shorter and means something different the moment another stop is added, which is exactly when you least want the rest of the gradient to move.

Fading to nothing

A linear gradient to a transparent colour is how a scrim over a photograph is made — the gradient darkens the bottom of the image so the caption reads, and disappears at the top.

A scrim
background: linear-gradient(  180deg,  rgba(15, 23, 42, 0.8) 0%,  rgba(15, 23, 42, 0) 100%);

Note that both ends name the same colour. Fading to the keyword transparent works in current browsers, and in older ones dragged the fade through black, because transparent is a transparent black. Naming the colour at both ends has always been safe.

Radial gradient in CSS

A radial gradient spreads outwards from a point. It has no angle; it has three other things instead.

Shape

circle stays round whatever the box, so in a wide banner it covers the height and overflows the width. ellipsestretches to match the box’s proportions, which is the default and usually what you want for a background.

Size

Four keywords, each answering “the last stop reaches which part of the box?”

  • farthest-corner — the default, and the only one that guarantees the gradient covers the whole box.
  • farthest-side — reaches the furthest edge; the corners lie beyond the last stop and take its colour flat.
  • closest-side — reaches the nearest edge. A tight circle with a large flat surround.
  • closest-corner — between the two closest options.

Position

Where the centre sits, as a pair of percentages or a keyword. Moving it off centre is what turns a symmetrical blob into a light source.

A spotlight from the upper left
background: radial-gradient(circle at center, #4f46e5, #06b6d4); background: radial-gradient(  ellipse closest-side at 30% 30%,  #fbbf24,  #dc2626);

Conic gradient in CSS

A conic gradient sweeps around a point rather than outwards from it. The colours are laid around a circle, like the numbers on a clock face.

Starting angle and position

from says where the sweep begins, measured clockwise from north like every other CSS angle. at says where the centre is. Both default sensibly: from 0deg at center.

A sweep starting at three o'clock
background: conic-gradient(  from 90deg,  #4f46e5,  #06b6d4,  #22c55e);

What it is actually for

  • Pie and donut charts. Hard stops at the right percentages give you segments; a radial mask over the middle makes it a donut. No library, no canvas.
  • Progress rings. Two stops at the same percentage produce a hard edge that sweeps as the number changes.
  • Colour wheels. The full hue circle in one declaration, which is what the transparency chequerboard on this page is built from.
  • Conical shine. A subtle sweep across a button or a card edge, the way a metallic surface catches light.

Conic gradients arrived after the vendor-prefix era, so they never had a prefix and are supported everywhere current. The one gap: SVG has no conic gradient, so exporting one as SVG can only approximate it — the PNG export is faithful because the browser paints it.

CSS gradient colour stops explained

A colour stop is a colour and a position: this colour, at full strength, here. Everything between two stops is interpolated, and everything before the first or after the last is held flat.

The same three colours, paced two ways
/* even — each colour gets a third of the run */linear-gradient(90deg, #4f46e5 0%, #06b6d4 50%, #22c55e 100%) /* weighted — indigo dominates, green is a hint at the end */linear-gradient(90deg, #4f46e5 0%, #06b6d4 80%, #22c55e 100%)

Two stops at the same position make a hard edge

There is no gap for the browser to blend across, so the colour changes instantly. That is not a bug to work around — it is how stripes, two-tone splits and pie segments are made.

Stripes, from hard edges and a repeat
background: repeating-linear-gradient(  45deg,  #0f172a 0%,  #0f172a 10%,  #1e293b 10%,  #1e293b 20%);

Implicit positions are a trap

Leave the percentages out and the browser spreads the stops evenly — which is fine until you add a fourth colour and all three of the others move. Writing the positions costs a few characters and means the gradient you built stays the gradient you have.

Alpha interpolates too

A stop can be translucent, and the transition blends the transparency along with the colour. The subtlety worth knowing: a correct implementation premultiplies alpha before blending. Without that, fading red to a transparent colour drags the midpoint through whatever RGB the transparent stop carries — usually black — and the fade goes grey. This tool premultiplies, so red fading to nothing stays red the whole way.

CSS gradient best practices

Contrast is measured at the worst point, not on average

A gradient has a different contrast ratio everywhere along it. If white text needs 4.5:1 it needs 4.5:1 at every point the text touches, and an average hides exactly the spot where a word disappears. The practical consequence: a gradient with text on it should stay within one lightness band rather than running light to dark. The colour picker checks a single pair against the WCAG thresholds, which is the test to run on the darkest and lightest points of the blend.

Keep text off the gradient where you can

A solid panel over the gradient, or a scrim between the two, solves the problem outright and costs one extra element. Gradient text — clipped with background-clip — is harder again, because thin letterforms need far more contrast than a filled shape does.

Smooth transitions come from close colours

Two hues far apart on the wheel pass through everything between them, and in sRGB that route usually goes somewhere muddy — blue to yellow travels through grey. Either keep the hues close, or add a stop at the midpoint to steer the path through a colour you chose — the colour converter will give you the HSL reading of each stop, which is where a hue distance is easiest to see.

Two or three colours, rarely more

Past about four stops a gradient stops reading as a blend and starts reading as bands. If the design needs more colour than that, two stacked gradients with different opacities usually looks better than one with six stops.

Performance: it is the animation that costs

A static gradient is painted once and is cheaper than downloading the equivalent image. Animating the stops is not — that forces a repaint every frame. Cross-fade the opacity of two stacked layers instead, which the compositor can do on the GPU.

Compatibility: no prefixes needed

Linear and radial gradients have been unprefixed since 2013, and conic gradients never had a prefix. Emitting -webkit- copies today adds bytes and implies a support problem that does not exist. The toggle is there for house styles that still demand it, and off by default.

Name it once

The moment a gradient appears in two places, put it in a custom property. It becomes one thing to change rather than two to keep in step — and once the rule is pasted into a stylesheet, the CSS formatter will re-indent it to match the rest of the file.

Declared once, used anywhere
:root {  --gradient-brand: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);} .hero { background: var(--gradient-brand); }.button { background: var(--gradient-brand); }

CSS gradient vs solid colour

A gradient is more interesting than a flat colour and harder to put content on. That trade is the whole decision.

Use a gradient when the surface is mostly decorative

Heroes, section dividers, card headers, empty states, call-to-action buttons, splash screens. Surfaces where the job is to be memorable and there is little or no text to protect. Small elements are especially good candidates, because the whole gradient is visible at once and reads as one thing.

Use a solid colour when the surface holds content

Body text, forms, tables, dashboards, anything dense. Contrast that changes as your eye travels is tiring in a way people do not consciously notice and do notice: they read more slowly. A flat background is one decision the reader never has to make.

The middle path

Gradient behind, solid on top. A gradient page background with white cards over it gives the atmosphere without the cost, and is why nearly every marketing site is built that way.

One more argument for solid: a gradient is a commitment. Changing a brand colour means finding every gradient it appears in and rebalancing the stops, where a flat colour is one value. If the colour is not settled, flat is the reversible choice.

Common CSS gradient use cases

The same three declarations, doing rather different jobs. What changes between them is mostly how much contrast the surface has to preserve.

Website backgrounds

A wide, low-contrast gradient across a page gives depth without a single image request. Keep it within one lightness band so the text on top reads the same everywhere.

Hero sections

The commonest use there is. A diagonal linear gradient behind a headline, usually dark enough throughout for white text — check the pale end rather than assuming.

Buttons

Small enough that the whole gradient is visible at once, which is where they work best. White label text needs every stop dark enough, not just the average.

Cards

A gradient header over a plain body: decoration where it helps and a flat surface where the content lives. The best of both.

Landing pages

Section-to-section gradients give a long page rhythm without images. Repeating the same two brand colours at different angles ties it together.

Text effects

background-clip: text clips a gradient to the letters. Striking at display sizes and unreadable at body sizes, because thin strokes need far more contrast than a filled shape.

Branding

A gradient built from two brand colours becomes a recognisable asset. Put it in a custom property once and it stays consistent everywhere it appears.

Mobile interfaces

Gradients scale to any screen with no asset pipeline, which matters most where bandwidth does. A single declaration replaces a set of exported @1x, @2x and @3x images.

Dashboard UI

Sparingly. A gradient behind a metric card is fine; one behind a table is not, because contrast that changes across the surface makes rows harder to scan.

Marketing sites

Where gradients earn the most, because the surfaces are largely decorative and the job is to be memorable rather than to hold dense content.

Frequently asked questions

What is a CSS gradient?

A smooth transition between two or more colours, drawn by the browser rather than loaded as an image. It is a value for background-image, so it scales to any size with no file to download, no resolution to get wrong and nothing to go blurry on a retina screen. Three kinds exist: linear, which travels in a straight line; radial, which spreads from a point; and conic, which sweeps around one.

Is this CSS Gradient Generator free?

Yes. Every gradient type, every preset, the transparency, the accessibility check and all five export formats are free, with no account, no sign-up, no watermark and no limit. There is nothing to unlock.

Is my gradient data uploaded?

No. The gradient is built, previewed, analysed and exported by JavaScript running in your browser. Nothing is sent to a server, nothing is stored remotely and nothing is logged. The history is kept in this browser's local storage and never syncs — clearing your site data clears it.

Can I create linear gradients?

Yes, with either a direction keyword or a custom angle. The eight keywords — to right, to bottom left and so on — point at that side or corner whatever shape the box is. A fixed angle does not, which is why the two only agree in a square: to bottom right is 135° in a square and something else in a wide banner. Pick the keyword when you mean the corner and the angle when you mean the angle.

Can I create radial gradients?

Yes, with a shape, a size and a centre. Circle stays round and overflows the narrow axis; ellipse stretches to the box. The size keyword decides where the last stop lands — farthest-corner is the default and the only one that guarantees the gradient covers the whole box, while closest-side gives a tight circle with the corners painted flat in the final colour.

Can I create conic gradients?

Yes, with a starting angle and a centre. A conic gradient sweeps around a point like a colour wheel, which makes it the one-line way to draw a pie chart, a progress ring or a colour picker. Support is universal in current browsers. Note that it has no equivalent in SVG, so the SVG export approximates it and says so.

Can I add more than two colors?

Up to twelve stops. Click the bar to add one where you clicked, and it takes the colour the gradient already has there — so adding a stop changes nothing until you move it, which is what you want when the point is to pin something before bending it. Past about six stops a gradient usually reads as bands rather than a blend.

Can I control color stop positions?

Precisely. Drag a handle on the bar, type a percentage in the list, or use the arrow keys for one percent at a time and Shift for ten. Positions are always written into the CSS rather than left implicit, because an implicit position means something different the moment another stop is added.

What do color stop percentages actually do?

They say where along the gradient line each colour is at full strength. Everything between two stops is interpolated, and everything before the first or after the last is that colour held flat. Two stops at the same percentage make a hard edge with no blend at all, which is how you build a stripe or a two-tone split in one declaration.

Can I copy the generated CSS?

In several forms, because a gradient ends up in different places: the full declaration with a solid fallback, the background property on one line, the bare gradient value for a mask or a border image, a minified version, and a CSS custom property. There is also SCSS, JSON and Tailwind. Each has its own copy button and shows a confirmation.

Can I paste a gradient I already have?

Yes — that is what the Paste CSS button is for. It reads linear, radial and conic gradients, repeating or not, with any colour notation, and either a whole declaration or just the value. Implicit stop positions are filled in the way a browser fills them. If it cannot read something it says so rather than guessing, because a gradient editor that mangles what you pasted is worse than one that admits it.

Can I create transparent gradients?

Every stop has its own alpha, with 0, 25, 50, 75 and 100 percent available in one click and anything in between on the slider. Turn on the transparency chequerboard to see what is actually transparent rather than merely pale. Translucent stops are written as rgba(), which says how transparent a colour is in a way an eight-digit hex does not.

Why does fading to transparent go grey in some tools?

Because they interpolate the colour channels straight. A fully transparent colour still has RGB values, and blending them in drags the fade through whatever those happen to be — usually the black that transparent defaults to. The right way is to premultiply alpha, which is what this tool does, so red fading to nothing stays red the whole way. If you hit this elsewhere, write the transparent end as rgba with the same colour rather than the keyword transparent.

Can I use gradients with Tailwind CSS?

Sometimes directly and always indirectly. Tailwind's built-in utilities cover linear gradients in the eight compass directions with up to three opaque stops — the from, via and to classes. Anything beyond that, which is most interesting gradients, needs either an arbitrary value or a theme entry. The Tailwind tab tells you which case you are in, and when the classes will not work it names the reason rather than quietly producing something that looks close.

What is the gradient angle measured from?

North, going clockwise. 0deg points up, 90deg points right, 180deg points down. That is the opposite convention from the mathematical one, where angles run anticlockwise from east, and it is why so many gradients come out 90 degrees off when converted by hand. The angle is the direction the gradient travels, not the direction it comes from.

Are the generated gradients responsive?

Yes, inherently. A gradient has no fixed size — it is painted across whatever box it is applied to, at whatever size that box happens to be, and it repaints on resize. That is one of the main arguments for a CSS gradient over an exported image, which has a resolution and a file size and looks wrong at any other dimensions.

Do CSS gradients need vendor prefixes?

No. Linear and radial gradients have been unprefixed in every browser since 2013, and conic gradients never had a prefix at all — they arrived after the prefix era ended. The toggle exists because some house styles still require them, and it is off by default because writing a prefix implies it is needed.

Is text readable over a gradient?

It depends where on the gradient the text falls, which is why this tool does not report a single contrast ratio. A gradient has a different one at every point, so an average would hide the exact spot where the text vanishes. The Analysis tab reports the worst point, says where along the run it is, shows what proportion clears each WCAG threshold, and draws a bar so the bad stretch is visible rather than described.

How do I make text on a gradient accessible?

Aim for 4.5:1 at every point rather than on average, which usually means keeping the gradient within one lightness band instead of running light to dark. Where the design needs a wide range, put the text on a solid panel over the gradient, or add a subtle scrim between the two. Gradient text — the background-clip trick — is harder still, because thin letterforms need far more contrast than a filled shape does.

When should I use a solid colour instead?

Whenever the surface holds content. Body text, form fields, tables and dense interfaces all read better on a flat colour, because a gradient behind them means the contrast changes as your eye moves. Gradients earn their place on surfaces that are mostly decorative — a hero, a card header, a call-to-action button, an empty state — and on small elements where the whole gradient is visible at once.

Do gradients affect performance?

Barely, in normal use. A gradient is painted once by the compositor and costs less than downloading and decoding an equivalent image. The two things that do cost: animating a gradient's stops, which forces a repaint every frame and should be done by animating opacity between two stacked layers instead; and very large repeating gradients used as patterns, which can be expensive to tile.

What is a repeating gradient for?

Patterns. A repeating gradient tiles the stop sequence instead of holding the end colours, which turns a two-stop gradient with hard edges into stripes and a conic one into a starburst. The thing to know is that the last stop has to be below 100% or there is nothing left to repeat into — the sequence fills the box once and the repeat never happens.

Can I export the gradient as an image?

Yes, as PNG or SVG. The PNG is rendered by the browser from the real CSS, so what downloads is what you see — including a conic gradient, which a canvas has no primitive for. The SVG is a real vector gradient for linear and radial; SVG has no conic gradient, so that one is approximated and the file says so in a comment.

What happens to my gradient history?

It stays in this browser. Up to twenty-four recent gradients are kept in local storage, deduplicated so making the same one twice moves it to the front rather than filling the list. You can load, copy or delete any of them, or clear the lot. Nothing is uploaded and nothing syncs between devices.

Are there keyboard shortcuts?

Ctrl/Cmd+G generates a random gradient, Ctrl/Cmd+Shift+C copies the CSS, Ctrl/Cmd+Shift+R resets everything and Ctrl/Cmd+Shift+D downloads the CSS file. On the stop bar the arrow keys move a stop by one percent, Shift by ten, Home and End send it to the ends, and Delete removes it.

Popular tools

↑ ↓NavigateOpenEscClose