Gradient Generator

Create beautiful CSS gradients with multiple colors, angles, and gradient types for your web projects.

Gradient Settings

%
%

Preview

CSS Code

CSS Property
background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%);
Gradient Value
linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%)

How CSS Gradients Work

A CSS gradient is a smooth visual transition between two or more colors rendered entirely by the browser — no image file required. Because gradients are generated programmatically, they scale perfectly to any resolution, load instantly, and can be updated with a single line of code. This gradient generator builds the correct CSS syntax for you so you can copy and paste production-ready code directly into your stylesheet.

Every gradient consists of at least two color stops: a color value paired with a position (expressed as a percentage of the gradient's total length or radius). The browser interpolates colors between each stop using its built-in color-mixing algorithm, creating the smooth transitions you see in the preview.

Three gradient functions are supported by all modern browsers:

  • linear-gradient — colors transition along a straight line at a specified angle.
  • radial-gradient — colors radiate outward from a focal point in a circle or ellipse shape.
  • conic-gradient — colors sweep around a central point like the hands of a clock, creating pie-chart-style effects.

Understanding the underlying CSS syntax helps you fine-tune gradients beyond what any visual tool provides. The sections below break down each gradient type, explain the formula this tool uses, and show real worked examples you can adapt immediately.

Gradient CSS Syntax and Formula

Each gradient type has a distinct function signature. This generator produces output that matches these signatures exactly, so the copied code will work in any modern browser without modification.

Linear Gradient

The formula for a linear gradient as generated by this tool is:

linear-gradient(<angle>deg, <color1> <pos1>%, <color2> <pos2>%, ...)

Color stops are first sorted by ascending position, then joined with commas. The angle controls the direction of the color flow: 0deg flows bottom-to-top, 90deg flows left-to-right, 180deg flows top-to-bottom, and 270deg flows right-to-left.

Radial Gradient

radial-gradient(<shape> at <position>, <color1> <pos1>%, ...)

Shape is either circle or ellipse. Position sets the focal center using keywords such as center, top left, or bottom right.

Conic Gradient

conic-gradient(from <angle>deg at <position>, <color1> <pos1>%, ...)

The from angle rotates the entire sweep, and the position keyword sets the center point around which colors rotate.

CSS Gradient Output Formulas

linear-gradient(Adeg, C1 P1%, C2 P2%, ...) | radial-gradient(S at POS, C1 P1%, ...) | conic-gradient(from Adeg at POS, C1 P1%, ...)

Where:

  • A= Angle in degrees (0–360) for linear and conic gradients
  • C1, C2, ...= Hex or RGB color values for each color stop, sorted by position
  • P1, P2, ...= Position of each color stop as a percentage (0–100%)
  • S= Radial shape: circle or ellipse
  • POS= Position keyword: center, top, bottom, left, right, top left, etc.

Linear Gradient: Angles, Directions, and Color Stops

Linear gradients are the most commonly used gradient type on the web. They appear in hero backgrounds, buttons, cards, overlays, and navigation bars. The key parameter is the angle, which ranges from 0 to 360 degrees and determines the direction colors flow across the element.

Common angle shortcuts you will encounter in CSS documentation use directional keywords like to right (equivalent to 90deg), to bottom (180deg), and to bottom right (135deg). This tool generates the numeric degree form, which is unambiguous and has universal browser support.

Adding a third or fourth color stop dramatically changes the visual impact of a linear gradient. A three-stop gradient might use a bright color in the center that fades to dark shades on both ends, creating a spotlight effect. The position percentage of each stop tells the browser exactly where that color should appear at full intensity — for example, a stop at 50% sits exactly in the middle of the element.

Angle Direction CSS Keyword Equivalent
0degBottom to Topto top
90degLeft to Rightto right
135degTop-left to Bottom-rightto bottom right
180degTop to Bottomto bottom
270degRight to Leftto left

When designing with linear gradients, consider the reading direction of your audience. Left-to-right gradients (90deg) feel natural in left-to-right languages, while diagonal gradients (45deg or 135deg) add energy and dynamism to a layout. You can up to 6 color stops with this tool, which is more than enough for virtually any design need.

Radial and Conic Gradients: Shape, Position, and Sweep

Radial and conic gradients extend the creative possibilities far beyond straight-line transitions. Each serves distinct design goals and produces visually unique results.

Radial Gradients

A radial gradient radiates outward from a focal point. You control two key parameters: the shape (circle or ellipse) and the position of the center point. A circle maintains equal radius in all directions, producing perfectly round color rings. An ellipse stretches to fill its container, adapting its proportions to the element's width and height.

Positioning the center away from the middle creates spotlight or lens-flare effects. A radial gradient centered at top left with a bright inner color and dark outer color mimics a corner light source, adding depth to flat interfaces. Centered at bottom, the same gradient can simulate a ground glow effect popular in dark-mode designs.

Conic Gradients

A conic gradient sweeps colors around a central point like a color wheel or pie chart. Unlike linear and radial gradients which blend along a line or radius, conic gradients blend around an angle. The from angle rotates the starting point of the sweep, and the position sets the center of rotation.

Conic gradients are ideal for creating pie charts, donut charts, color pickers, and starburst decorative elements. When the first and last color stops are the same color, the gradient appears seamless, creating a continuous color wheel effect. This tool supports the full range of positions and angles for conic gradients, giving you complete creative control.

All three gradient types fully support transparency via RGBA or HSL color values with alpha channels — though the hex color picker in this tool outputs solid hex values, you can manually edit the copied CSS to add transparency as needed.

Gradient Best Practices for Web Design

Gradients are a powerful design element, but like any tool they can be misused. Following these principles will help you create gradients that enhance your UI rather than distract from it.

Contrast and Accessibility

Text placed over a gradient background must maintain sufficient contrast at every point along the gradient, not just the average. The WCAG 2.1 standard requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text. Because a gradient varies in color across its length, a dark gradient that starts readable may become unreadable at its lightest point. Always check contrast at both the lightest and darkest ends of any gradient used behind text.

Performance Considerations

CSS gradients are rendered by the GPU and are extremely lightweight compared to image files. A complex six-stop gradient adds essentially zero kilobytes to your page weight. However, animating gradient properties (like angle or color values) via JavaScript on every frame can be expensive. For animated gradients, prefer animating background-position on an oversized gradient background, which is GPU-accelerated and far more performant.

Color Harmony

The most visually appealing gradients typically use colors that are adjacent on the color wheel (analogous colors) or complementary pairs. Pure primary-to-primary transitions (red to blue, for example) often pass through a muddy gray midpoint. To avoid this, add an intermediate stop at 50% with a vivid intermediate hue, or use HSL color values and ensure the hue arc stays within a pleasing range.

Consistency Across a Design System

Define your gradient palette in CSS custom properties or design tokens so every gradient-using component draws from the same source of truth. This makes site-wide gradient updates a one-line change rather than a hunt-and-replace across dozens of files. The CSS output from this generator slots directly into a custom property definition.

Worked Examples

Blue-to-Purple Linear Gradient at 90 Degrees

Problem:

Create a horizontal linear gradient from #3b82f6 at 0% to #8b5cf6 at 100%.

Solution Steps:

  1. 1Select gradient type: Linear.
  2. 2Set the angle slider to 90 degrees.
  3. 3Set color stop 1: #3b82f6 at position 0%.
  4. 4Set color stop 2: #8b5cf6 at position 100%.
  5. 5Color stops sorted by position: ['#3b82f6 0%', '#8b5cf6 100%'], joined: '#3b82f6 0%, #8b5cf6 100%'.
  6. 6Generator outputs: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%).

Result:

background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%);

Three-Stop Sunset Radial Gradient

Problem:

Create a radial gradient from orange (#f97316) at 0% to pink (#ec4899) at 100%, centered at center, ellipse shape.

Solution Steps:

  1. 1Select gradient type: Radial.
  2. 2Set shape to: ellipse.
  3. 3Set position to: center.
  4. 4Set color stop 1: #f97316 at position 0%.
  5. 5Set color stop 2: #ec4899 at position 100%.
  6. 6Color stops string: '#f97316 0%, #ec4899 100%'.
  7. 7Generator outputs: radial-gradient(ellipse at center, #f97316 0%, #ec4899 100%).

Result:

background: radial-gradient(ellipse at center, #f97316 0%, #ec4899 100%);

Conic Gradient Color Wheel at 0 Degrees

Problem:

Create a conic gradient that sweeps from cyan (#06b6d4) at 0% to blue (#3b82f6) at 100%, starting from 0 degrees, centered at center.

Solution Steps:

  1. 1Select gradient type: Conic.
  2. 2Set the angle slider to 0 degrees.
  3. 3Set position to: center.
  4. 4Set color stop 1: #06b6d4 at position 0%.
  5. 5Set color stop 2: #3b82f6 at position 100%.
  6. 6Color stops string: '#06b6d4 0%, #3b82f6 100%'.
  7. 7Generator outputs: conic-gradient(from 0deg at center, #06b6d4 0%, #3b82f6 100%).

Result:

background: conic-gradient(from 0deg at center, #06b6d4 0%, #3b82f6 100%);

Four-Stop Purple Haze Linear Gradient at 135 Degrees

Problem:

Build a diagonal gradient using the Purple Haze preset: #8b5cf6 at 0%, #6366f1 at 50%, #ec4899 at 100%, at 135 degrees.

Solution Steps:

  1. 1Select gradient type: Linear.
  2. 2Set angle to 135 degrees.
  3. 3Set color stop 1: #8b5cf6 at 0%.
  4. 4Set color stop 2: #6366f1 at 50%.
  5. 5Set color stop 3: #ec4899 at 100%.
  6. 6Stops sorted and joined: '#8b5cf6 0%, #6366f1 50%, #ec4899 100%'.
  7. 7Generator outputs: linear-gradient(135deg, #8b5cf6 0%, #6366f1 50%, #ec4899 100%).

Result:

background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 50%, #ec4899 100%);

Tips & Best Practices

  • Use the preset buttons (Sunset, Ocean, Forest, Purple Haze) as starting points and then fine-tune colors and angles to match your brand palette.
  • For subtle, professional backgrounds, keep colors within 30 degrees of each other on the HSL color wheel and use low saturation values.
  • A 45-degree or 135-degree angle gives diagonal gradients that feel dynamic without being aggressive — great for hero sections.
  • Place your most important color stop closer to the center (40–60%) to give it more visual weight in the gradient.
  • To create a hard color break (no blend), set two adjacent color stops to the same position — for example, red at 50% and blue at 50% creates a sharp dividing line.
  • When using a gradient behind text, test contrast at both the lightest and darkest points of the gradient to meet WCAG accessibility standards.
  • Copy the gradient value (not the full CSS rule) when you need to use it inside a Tailwind style prop or a CSS-in-JS template literal.
  • Conic gradients at 90-degree increments with equal-width color stops create clean pie-chart slices — perfect for simple data visualizations without a charting library.

Frequently Asked Questions

A linear gradient transitions colors along a straight line at a specified angle, making it ideal for directional backgrounds and button fills. A radial gradient emanates colors from a central focal point outward in a circular or elliptical pattern, great for spotlight and glow effects. A conic gradient sweeps colors around a central point at varying angles, producing pie-chart or color-wheel visuals. All three are pure CSS and require no image files.
This generator supports up to 6 color stops per gradient. Most browsers support far more stops in CSS itself, but 2–6 stops cover virtually every practical design scenario. Each stop has an independent color (hex) and a position (0–100%). Stops are automatically sorted by position before the CSS is assembled, so you can add them in any order.
Muddy midpoints typically occur when two complementary colors (opposite on the color wheel, such as red and green, or blue and orange) are blended directly. The browser mixes through gray because the intermediate RGB values cancel each other out. To fix this, add an intermediate color stop at 50% with a vivid hue that bridges the two endpoint colors, or choose analogous colors that share a common hue component.
Yes. In CSS, gradient functions are treated as image values, so you can use them anywhere an image URL is accepted — including the background-image property, border-image, list-style-image, and even as a mask. You can also layer multiple gradients by separating them with commas in the background or background-image property, which allows for complex multi-layer effects.
The Tailwind output shown in the results panel uses arbitrary value syntax (e.g., from-[#3b82f6]) which requires Tailwind CSS v3.0 or later with JIT mode enabled. It only captures the first and last color values for a simple from/to gradient using bg-gradient-to-r. For multi-stop or non-horizontal gradients, use the plain CSS output and apply it via Tailwind's style prop or a custom utility class.
Linear and radial gradients have had universal support across Chrome, Firefox, Safari, and Edge since 2013 and require no vendor prefixes in modern code. Conic gradients gained full cross-browser support (including Safari) from 2021 onward and are safe to use without prefixes in any browser released after that year. For legacy IE support (which is effectively zero market share today), you would need a solid color fallback.
CSS cannot directly transition gradient color values because gradients are background-image values, and background-image is not animatable by the spec. The most performant workaround is to create an oversized gradient (e.g., 400% width) and animate background-position using a CSS keyframe animation — the browser GPU-accelerates position changes. Alternatively, you can use JavaScript or CSS Houdini's @property to register custom gradient properties as animatable.

Sources & References

Last updated: 2026-06-05

💡

Help us improve!

How would you rate the Gradient Generator?

<>

Editorial Note

MyCalcBuddy Editorial Team

This page is maintained as an educational calculator reference.

Source

Formula Source: Standard Mathematical References

by Various

UpdatedLast reviewed: May 2026
CheckedFormula checks are based on standard references and internal QA review.