ToolNimba

๐ŸŽจ CSS Gradient Generator: Build Linear and Radial Gradients

Shihab Mia By Shihab Mia ยท Updated 2026-07-18

Paste this into any element's style to apply the gradient background.

This CSS gradient generator builds a smooth linear or radial gradient by eye and hands you the exact background code in one click. For example, picking indigo and pink at a 90 degree angle produces background: linear-gradient(90deg, #4F46E5, #EC4899); ready to paste. Choose two or three colors, drag the angle for linear gradients, and watch a live preview update as you go, all in your browser with no sign-up, no uploads, and no waiting.

What is the CSS Gradient Generator?

A CSS gradient is a smooth transition between two or more colors that the browser renders as a background image without loading a single image file. Because the gradient is drawn from code rather than a downloaded picture, it stays razor sharp at every zoom level and screen density, adds nothing to your page weight, and can be recolored instantly by editing a few characters. A good gradient generator hides the syntax behind color pickers and a live preview so you can focus on how the blend looks rather than memorizing the exact punctuation the browser expects. The quickest way to learn the pattern is to build one here, read the generated line, and paste it straight into your stylesheet.

The two shapes this gradient generator produces are linear and radial. A linear gradient runs colors along a straight line across the box, and you control the direction with an angle: linear-gradient(90deg, #4F46E5, #EC4899) sweeps left to right, while 180deg runs top to bottom and 0deg runs bottom to top. A radial gradient instead spreads outward from a center point like a spotlight, written as radial-gradient(circle, #4F46E5, #EC4899), so the first color sits in the middle and the last color reaches the edges. This linear gradient generator and radial gradient generator share the same color controls, so you can flip between the two shapes and compare them without redoing your palette. CSS also defines a third type, the conic gradient, which sweeps colors around a center like a color wheel and powers pie charts and angular effects; it is worth knowing about even though this background gradient generator focuses on the two shapes designers reach for most.

Color stops are the heart of any gradient. Each stop is a color, and the browser fills the space between stops with a seamless blend. Two stops give you a simple fade; adding an optional third stop lets you pass through a middle hue, which is how designers create sunset skies, brand ribbons, and eye-catching hero banners. The order matters: in a linear gradient the stops are read along the angle line, and in a radial gradient they are read from the center outward. By default our css gradient maker spaces the stops evenly, which is the sensible choice that covers the vast majority of real designs. In hand-written CSS you can also pin a stop to a position, such as linear-gradient(90deg, #4F46E5 0%, #EC4899 60%), to bias the blend toward one side, and placing two stops at the same position creates a hard line instead of a fade, the trick behind stripes and split backgrounds.

Angle is the one control unique to linear gradients, and CSS measures it clockwise from pointing straight up. That means 0deg points the gradient toward the top, 90deg toward the right, 180deg toward the bottom, and 270deg toward the left. A 45deg diagonal is the classic choice for cards and buttons because it feels dynamic without being distracting. You can also write the direction as a keyword, so to right equals 90deg and to bottom right equals roughly 135deg on a square box; the numeric form this online gradient tool outputs is exact and works everywhere. Because the angle is just a number from 0 to 360, you can nudge it one degree at a time to line the color transition up precisely with the shape it sits behind. Radial gradients ignore the angle entirely, so the gradient generator hides that control when you switch to radial.

Once you are happy with the blend, the output is a single background declaration you paste straight into your stylesheet or an inline style attribute: background: linear-gradient(90deg, #4F46E5, #EC4899);. That one line works in every modern browser on any element, from a full-page hero to a tiny badge, and it scales to any size because the browser recomputes the gradient rather than stretching a bitmap. According to MDN Web Docs, linear-gradient, radial-gradient, and conic-gradient are all baseline features supported across current Chrome, Firefox, Safari, and Edge without vendor prefixes, so the clean code this gradient generator produces needs no fallbacks for today's browsers (developer.mozilla.org/en-US/docs/Web/CSS/gradient). You can also drop the value into CSS custom properties, Tailwind arbitrary values, or a design token so the same gradient stays consistent across a whole site.

Gradients reward restraint. Two colors that are close in hue read as premium and calm, while wildly different colors can look muddy where they meet because the midpoint blends toward gray. If a two-color blend looks dull in the middle, enabling the third stop with a brighter transitional color usually fixes it. You can also add transparency for overlays: because an rgba color or a color with an alpha channel can be a stop, a gradient from a solid color to a fully transparent one creates a fade-to-clear scrim that is perfect for darkening the bottom of a hero image behind white text. Keeping the whole thing accessible matters too, since a gradient changes brightness across its width, so preview your real text against the lightest and darkest parts of the blend before you ship and make sure it clears WCAG contrast at every point.

When to use it

  • Designing a hero banner or landing-page background with a modern two or three color blend.
  • Creating gradient buttons, badges, and cards without exporting a single image file.
  • Prototyping brand color directions quickly by swapping stops and comparing linear versus radial.
  • Generating a background value to drop into a CSS custom property or a Tailwind arbitrary class.
  • Matching a gradient in a design mockup by dialing in the exact hex colors and angle.
  • Building a fade-to-transparent overlay so white text stays readable on top of a photo.
  • Teaching or learning how the linear-gradient and radial-gradient syntax maps to a visual result.

How to use the CSS Gradient Generator

  1. Choose Linear or Radial from the gradient type menu at the top.
  2. Pick color stop 1 and color stop 2 with the swatches, or type a hex value directly.
  3. For a richer blend, tick Enable on color stop 3 and choose a middle color.
  4. For linear gradients, drag the angle slider or type a value from 0 to 360 degrees.
  5. Watch the live preview box update, then read the generated CSS below it.
  6. Click Copy CSS and paste the background declaration into your stylesheet.

Formula & method

Linear: background: linear-gradient(deg, color1, color2 [, color3]); where the angle is measured clockwise from the top, so 0deg points up, 90deg right, 180deg down, 270deg left. Radial: background: radial-gradient(circle, color1, color2 [, color3]); where color1 is the center and the final color reaches the edges. With no explicit stop positions the browser spaces the colors evenly across the shape. Optional stop positions, such as color2 60%, bias the blend, and two stops at the same position create a hard edge.
CSS gradient generator: linear angle directions and linear versus radial shapesLinear Gradient Angles0degbottom to top90degleft to right180degtop to bottom45degdiagonalLinear vs Radial Shapelinear-gradient()radial-gradient()

Worked examples

You want a diagonal indigo-to-pink header background for a marketing page.

  1. Set gradient type to Linear.
  2. Set color stop 1 to #4F46E5 (indigo) and color stop 2 to #EC4899 (pink).
  3. Leave color stop 3 disabled for a clean two-color fade.
  4. Drag the angle to 45 for a diagonal sweep from bottom-left to top-right.

Result: background: linear-gradient(45deg, #4F46E5, #EC4899);

You need a warm radial "spotlight" background behind a centered logo.

  1. Set gradient type to Radial (the angle control disappears because radial ignores it).
  2. Set color stop 1 to #F59E0B (amber) as the center.
  3. Set color stop 2 to #B45309 (deep amber) for the outer edge.
  4. Copy the generated declaration and apply it to the container.

Result: background: radial-gradient(circle, #F59E0B, #B45309);

You want a three-color sunset banner that passes through orange.

  1. Keep gradient type on Linear and set the angle to 180 for a top-to-bottom flow.
  2. Set color stop 1 to #4F46E5 (dusk blue) at the top.
  3. Enable color stop 3 and set it to #F59E0B (orange) as the middle.
  4. Set color stop 2 to #EC4899 (pink) for the bottom, so the order reads blue, pink, orange along the line.

Result: background: linear-gradient(180deg, #4F46E5, #EC4899, #F59E0B);

Common linear gradient angles and the direction they point

AngleDirection of the blendEquivalent keyword
0degBottom to topto top
45degBottom-left to top-rightto top right
90degLeft to rightto right
135degTop-left to bottom-rightto bottom right
180degTop to bottomto bottom
270degRight to leftto left

Linear, radial, and conic gradients compared

PropertyLinear gradientRadial gradientConic gradient
Shape of blendStraight line across the boxCircle or ellipse from a centerSweep around a center point
Direction controlAngle from 0 to 360 degreesNo angle; spreads outwardStart angle and from position
First color sitsAt the start of the angle lineIn the centerAt the start angle
Typical useHeaders, buttons, ribbonsSpotlights, glows, orbsPie charts, color wheels, angular UI
CSS functionlinear-gradient()radial-gradient()conic-gradient()
In this toolYesYesEducational; write by hand

Popular gradient color pairs to copy

NameColor stop 1Color stop 2Suggested angle
Indigo to pink#4F46E5#EC489990deg
Sunset#F59E0B#EF4444135deg
Ocean#0EA5E9#2563EB90deg
Mint#10B981#14B8A645deg
Grape#7C3AED#DB2777135deg
Slate fade#64748B#1E293B180deg

Common mistakes to avoid

  • Using the wrong angle reference. CSS measures gradient angles clockwise from straight up, not from the horizontal. If your blend runs the wrong way, remember 90deg is left-to-right and 180deg is top-to-bottom, then adjust from there.
  • Expecting the angle to affect a radial gradient. Radial gradients spread outward from a center and ignore angle entirely. That is why the angle control disappears when you switch to radial; change the colors or their order instead.
  • Picking colors that muddy in the middle. Two colors on opposite sides of the wheel blend toward gray at their midpoint. If the center looks dull, enable a brighter third stop or choose two hues that sit closer together.
  • Forgetting text contrast over the gradient. A gradient changes brightness across its width, so text that is readable on one end can vanish on the other. Check your real text against both the lightest and darkest parts of the blend.
  • Typing an invalid hex value. A hex color needs three or six hex digits, like #F0A or #FF00AA. If a swatch will not update, check for a missing digit or a stray character; the tool shows a friendly error until the value is valid.
  • Reversing the stop order by accident. The colors are read in order along the angle line (or from center outward for radial). Swapping stop 1 and stop 2 flips the whole gradient, which is an easy fix but a common surprise.

Glossary

Gradient
A smooth transition between two or more colors, drawn by the browser as a background image from CSS code.
Linear gradient
A gradient whose colors blend along a straight line across the element, controlled by an angle.
Radial gradient
A gradient whose colors spread outward from a center point in a circle or ellipse.
Conic gradient
A gradient whose colors sweep around a center point like a color wheel, written with conic-gradient().
Color stop
A single color in a gradient; the browser blends smoothly between consecutive stops.
Stop position
An optional length or percentage after a color, such as #EC4899 60%, that pins where that stop falls.
Angle
For linear gradients, the direction of the blend in degrees, measured clockwise from straight up.
Hex color
A color written as a hash plus three or six hexadecimal digits, such as #EC4899.
Alpha channel
The transparency part of a color; a stop that fades to transparent creates a see-through overlay.
Custom property
A reusable CSS variable, like --brand, that can store a gradient value for use across a site.

Frequently asked questions

What is a CSS gradient generator?

A CSS gradient generator is a visual tool that lets you build a gradient by picking colors and an angle, then gives you the exact background code to paste into your stylesheet. This gradient generator handles both linear and radial gradients and previews the result live, so you never write the syntax by hand.

How do I create a linear gradient in CSS?

Use the css linear-gradient function inside a background declaration, for example background: linear-gradient(90deg, #4F46E5, #EC4899);. The first value is the angle and the rest are your color stops. In this linear gradient generator you set those with pickers and a slider, then copy the finished line.

What does the angle number mean in a linear gradient?

The angle sets the direction of the blend, measured clockwise from straight up. So 0deg goes bottom to top, 90deg goes left to right, 180deg goes top to bottom, and 270deg goes right to left. A 45deg angle gives the popular diagonal look.

What is the difference between a linear and a radial gradient?

A linear gradient blends colors along a straight line whose direction you set with an angle. A radial gradient spreads colors outward from a center point like a spotlight, with the first color in the middle and the last at the edges. Radial gradients ignore the angle setting entirely.

How do I make a gradient with three or more colors?

Enable the optional third color stop in this css gradient maker and choose a middle color. The browser blends stop 1 into stop 3 and then stop 3 into stop 2, which is how you build sunset and multi-hue effects. In hand-written CSS you can list as many colors as you like, separated by commas.

What is a conic gradient and does this tool make one?

A conic gradient sweeps its colors around a center point like a color wheel, written with conic-gradient(), and it is used for pie charts and angular UI effects. This gradient generator focuses on linear and radial gradients, but conic gradients use the same color-stop idea if you write them by hand.

How do I make a transparent or fade-out gradient?

Use a color with an alpha channel as one of your stops, for example linear-gradient(180deg, rgba(0,0,0,0.7), rgba(0,0,0,0)). The blend fades from a solid color to fully transparent, which is the standard way to darken the bottom of a hero image so white text stays readable.

How do I position color stops with percentages?

Add a percentage after a color to pin where it falls, such as linear-gradient(90deg, #4F46E5 0%, #EC4899 60%). Placing two stops at the same percentage creates a hard line instead of a fade, which is how you build stripes and split backgrounds.

Do CSS gradients work in all browsers?

Yes. The standard linear-gradient, radial-gradient, and conic-gradient functions are baseline features supported by every current browser with no vendor prefix. The code this online gradient tool produces is plain, standards-based CSS that works on desktop and mobile alike.

How do I use the gradient with Tailwind or a CSS variable?

Paste the gradient value (the part after background:) into a Tailwind arbitrary class like bg-[linear-gradient(90deg,#4F46E5,#EC4899)], or store it in a custom property such as --brand and reference it with background: var(--brand). This keeps one gradient consistent across your whole site.