Skip to main content
CalcChef

CSS Gradient Generator

Build linear, radial and conic gradients from color stops, ten presets or the colors of an image you upload, then copy CSS, Tailwind, React or SCSS code. How it works

Use the CSS Gradient Generator

Direction
90°
Color Stops
0%
100%
100%
100%
Colors from an image
CSS
background: linear-gradient(90deg, #ff0000 0%, #0000ff 100%);

Presets:

About the CSS Gradient Generator

linear-gradient(90deg, #ff0000 0%, #0000ff 100%) is the gradient this CSS gradient generator opens with: red to blue, left to right. Switch to radial or conic, pick one of eight direction keywords or a custom angle, add stops that each carry their own alpha and position, or take the colors from an image, and copy the result as CSS, Tailwind, a CSS variable, a React style or SCSS.

What a stop’s color box reads

TypedStored colorAlpha
#f00#ff0000100%
#ff000080#ff000050%
rgba(255, 0, 0, 0.5)#ff000050%
hsla(120, 100%, 50%, 1)#00ff00100%
hsla(240, 100%, 50%, 0.25)#0000ff25%
rgba(300, 0, 0, 1)RefusedThe stop keeps its last valid color
hsla(361, 50%, 50%, 1)RefusedThe stop keeps its last valid color
redRefusedThe stop keeps its last valid color

Color names are not read, and a value out of range is refused, not clamped. The text you type stays in the box while you type.

How to use this tool

  1. Pick linear, radial or conic, or start from one of ten presets, from Sunset to Pastel, or from an image under Colors from an image.
  2. For linear, tap a direction (right, left, top, bottom or one of the four corners) or Custom ° for an angle from 0 to 360. For radial set the shape, size and position, and for conic the start angle and position.
  3. Edit the stops: use the color swatch or type a color, then the position and alpha sliders. Click the bar to add a stop (a click within 10% of an existing stop adds none), drag a handle or use the position slider to move it, or double-click a stop to remove it. Two stops always remain.
  4. Choose CSS, Tailwind, CSS Variable, React or SCSS and copy. Use Save to keep the gradient in your list.

Frequently asked questions

How do I make a CSS gradient with transparency?
Give a stop an alpha with the alpha slider, or type rgba(), hsla() or #rrggbbaa in its color box. The stop is written as 8-digit hex: #ff0000 at 50% becomes #ff000080. At 100% alpha it stays a plain #rrggbb.
How do I write a CSS gradient in Tailwind?
Choose Tailwind. The default gradient gives bg-[linear-gradient(to_right,_#ff0000_0%,_#0000ff_100%)], with an underscore for every space. The angles 0, 90, 180 and 270 are written as to top, to right, to bottom and to left, and any other angle stays in degrees, such as 135deg. A corner keyword such as to bottom right is written only when you tap that direction, because the angle it gives depends on the shape of the box (MDN); a custom 135° stays 135deg.
Which angle points which way in a linear gradient?
0deg points up, 90deg right, 180deg down and 270deg left, and the angle grows clockwise. A gradient with no direction runs to the bottom, which is 180deg (MDN).
How does a conic gradient work?
Colors sweep clockwise around a center point, starting at the top. The start angle turns that starting point and the position moves the center, and stop positions are angles, or percentages where 100% is 360deg (MDN). The tool takes a start angle from 0 to 360 and one of nine positions, and writes conic-gradient(from 0deg at center, #ff0000 0%, #0000ff 100%) for the default stops.
Why does my typed color not change the gradient?
The box reads #rgb, #rrggbb, #rrggbbaa, rgba(r, g, b, a) and hsla(h, s%, l%, a) only. Names such as red, an rgba channel above 255, a hue above 360, saturation or lightness above 100% and an alpha above 1 are refused. The stop keeps its last valid color and the field says which forms it reads.
How do I turn an image into a CSS gradient?
Choose an image under Colors from an image. The browser shrinks it to 10 × 10 pixels on a white background and reads the four corners and the center. The first three different colors become the stops, at 0, 50 and 100% (two stops at 0 and 100% if there are only two, and white is added to a one-color image), in a linear gradient to the right. The file is read in this browser and is not uploaded. Then edit the stops like any others.

Related Tools

View all tools