About the CSS Gradient Generator
Pick your colors, set the angle or center, and the CSS gradient generator writes the linear-gradient(), radial-gradient() or conic-gradient() code while you watch the preview change. Copy it as a plain CSS background line or as a Tailwind CSS class; the checkerboard behind the preview shows exactly which parts are see-through.
A CSS gradient is an image the browser draws from a few numbers. It stays sharp on any screen and costs no extra download, which makes it a good fit for hero sections, buttons, overlays that keep text readable on a photo, and simple patterns like stripes or pie charts.
- Choose a Gradient Type (Linear, Radial or Conic), or start from one of the 10 Presets. Random picks two or three bright colors at a new angle.
- Set the direction. Linear has an Angle slider (Reset returns it to 90°). Conic has a Start angle and a Center. Radial has a Shape (Circle or Ellipse) and a Center with 9 choices, from Top left to Bottom right.
- Edit the Color Stops. Each row has a color picker, a text field and a Position slider with a percent box. The text field takes 3, 4, 6 or 8-digit hex and
rgb()orrgba(), such asrgb(255 0 0 / 50%); named colors andhsl()turn it red and aren't applied. - Add Color adds a stop, up to 10, and the X removes one (the last two always stay). Row order doesn't matter: stops are sorted by position in the code.
- Turn on Repeating for stripes or rings, with stops close together such as 0% to 10%. Toggle Size makes the preview taller or shorter.
- Copy the result from CSS Code or Tailwind CSS class.
InputGradient Type: Linear, Angle 90°
#FF0000 at 0%
#0000FF at 100%Outputbackground: linear-gradient(90deg, #FF0000 0%, #0000FF 100%);
bg-[linear-gradient(90deg,#FF0000_0%,#0000FF_100%)]InputGradient Type: Linear, Angle 180°
#0f172a00 at 0%
#0f172acc at 60%
#0f172a at 100%Outputbackground: linear-gradient(180deg, #0f172a00 0%, #0f172acc 60%, #0f172a 100%);
bg-[linear-gradient(180deg,#0f172a00_0%,#0f172acc_60%,#0f172a_100%)]Transparent at the top, solid at the bottom, so white text placed low stays readable. Add the photo as a second layer after a comma, linear-gradient(...), url(photo.jpg) center / cover; the first layer is drawn on top.
InputGradient Type: Conic, Start angle 0°, Center: center
#22c55e at 0% and 40%
#eab308 at 40% and 75%
#ef4444 at 75% and 100%Outputbackground: conic-gradient(from 0deg at center, #22c55e 0%, #22c55e 40%, #eab308 40%, #eab308 75%, #ef4444 75%, #ef4444 100%);Each pair of stops at the same position makes a hard edge, giving slices of 40%, 35% and 25%. Add border-radius: 50% to make it round.
InputLinear, Angle 45°, Repeating on
#3b82f6 at 0% and 5%
#93c5fd at 5% and 10%Outputbackground: repeating-linear-gradient(45deg, #3b82f6 0%, #3b82f6 5%, #93c5fd 5%, #93c5fd 10%);Linear, radial and conic gradients
Each function takes a direction or shape, then color stops. A stop's percentage is measured along the line for linear, outward from the center for radial, and around the circle for conic.
linear-gradient(angle, stops):0degpoints up and angles turn clockwise, so90degruns left to right. Without an angle the default isto bottom(180deg). Corner keywords liketo top rightadjust their angle to the element's shape.radial-gradient(shape at position, stops): spreads from a point as acircleor anellipse(the default). The generator uses the default size,farthest-corner; by hand you can writeclosest-sideor a length, as incircle 120px at center, for a smaller glow.conic-gradient(from angle at position, stops): sweeps around a point clockwise from the top. Use it for color wheels, pie charts and spinners.repeating-in front of any of them repeats the stops from the first position to the last.
Hard edges, transparency and fallbacks
Two stops at the same position switch color with no blend, which is how the pie chart and the Stripes preset get their sharp lines.
For transparency, use 8-digit hex such as #ff000080 (80 is about 50% opacity) or rgba(255, 0, 0, 0.5). Picking a new color with the picker keeps the stop's transparency. To fade out, end on the same color at zero alpha, like #0f172a00, rather than the transparent keyword, which some older browsers blended through gray.
A browser that can't read a gradient ignores the whole declaration. To support old browsers, put a plain color such as background: #2193b0; on the line before the gradient.
Browser support and Tailwind CSS
Linear and radial gradients work in every browser in use today. Conic gradients need Chrome 69, Edge 79, Safari 12.1 or Firefox 83.
CSS Code uses the background shorthand, which also resets background-color, background-size and the other background properties. If you set those separately, put the value in background-image instead. When the stylesheet is done, the CSS Minifier shrinks it without touching your gradients, and the HTML Minifier does the same for pages with a <style> block.
The Tailwind CSS class is an arbitrary value with spaces turned into underscores, since class names can't contain spaces. Tailwind v3 compiles it to background-image, and v4 reads the same class. v4 also has its own utilities: bg-linear-to-r (bg-gradient-to-r in v3), angles like bg-linear-45, bg-radial, bg-conic, and color space modifiers such as bg-linear-to-r/oklch.
Why some gradients look gray in the middle
Hex and rgb() colors are mixed in sRGB by default, and opposite colors meet in a dull middle: halfway from blue #0000ff to yellow #ffff00 is rgb(127.5, 127.5, 127.5), plain gray.
CSS Color Level 4 lets you pick the color space. Add in oklch after the angle and the middle stays bright. Chrome and Edge 111, Safari 16.2 and Firefox 127 support it, and older browsers skip the declaration, so keep a normal gradient above it.
background: linear-gradient(90deg, #0000ff, #ffff00);
background: linear-gradient(90deg in oklch, #0000ff, #ffff00);Gradient text, borders, page backgrounds and animation
Four common ways to use the gradient you copied. For text, write background before background-clip, because the shorthand resets the clip. For a rounded border, layer two backgrounds, since border-image ignores border-radius. For a page, give html a minimum height, or the gradient restarts below short content. To animate, register the angle with @property (Chrome 85, Safari 16.4, Firefox 128) and animate that, because browsers can't blend one gradient image into another.
.headline {
background: linear-gradient(90deg, #ff7e5f 0%, #feb47b 100%);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}.card {
border: 3px solid transparent;
border-radius: 12px;
background:
linear-gradient(#fff, #fff) padding-box,
linear-gradient(135deg, #2193b0 0%, #6dd5ed 100%) border-box;
}html {
min-height: 100%;
}
body {
background: linear-gradient(180deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
}@property --angle {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
.spinner {
background: conic-gradient(from var(--angle), #ff7e5f 0%, #feb47b 50%, #ff7e5f 100%);
animation: turn 3s linear infinite;
}
@keyframes turn {
to {
--angle: 360deg;
}
}How do I make a CSS gradient go from left to right?
Use 90deg or to right: linear-gradient(90deg, #ff7e5f, #feb47b). 0deg runs bottom to top, and with no direction the gradient runs top to bottom.
What is the difference between linear, radial and conic gradients?
A linear gradient changes color along a straight line, a radial one spreads outward from a point in circles or ellipses, and a conic one sweeps around a point like a clock hand, which suits pie charts and color wheels.
How do I make a gradient fade to transparent?
End on the same color with zero alpha, for example from #0f172a to #0f172a00, or from rgba(255, 0, 0, 0.5) to rgba(255, 0, 0, 0).
Why does my gradient look gray or muddy in the middle?
Hex and rgb() colors blend in sRGB by default, where opposite colors meet in gray. Add in oklch after the angle, as in linear-gradient(90deg in oklch, blue, yellow), to keep the middle saturated.
How do I put a gradient on text?
Set the gradient as the element's background, then add -webkit-background-clip: text, background-clip: text and color: transparent, so the gradient shows through the letters. The full snippet is in the In code tab.
Can you animate a CSS gradient?
Not directly: a transition between two gradients jumps instead of blending. Register an angle or color with @property, use it inside the gradient, and animate that property with @keyframes.
How do I use a CSS gradient in Tailwind CSS?
Paste the Tailwind CSS class, such as bg-[linear-gradient(90deg,#FF0000_0%,#0000FF_100%)], into your class attribute. It works in v3 and v4. For two-color gradients, v4 also offers bg-linear-to-r from-red-500 to-blue-500.