Gradient Generator
Create beautiful CSS gradients with multiple colors, angles, and gradient types for your web projects.
Gradient Settings
Preview
CSS Code
background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%);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
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 |
|---|---|---|
| 0deg | Bottom to Top | to top |
| 90deg | Left to Right | to right |
| 135deg | Top-left to Bottom-right | to bottom right |
| 180deg | Top to Bottom | to bottom |
| 270deg | Right to Left | to 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:
- 1Select gradient type: Linear.
- 2Set the angle slider to 90 degrees.
- 3Set color stop 1: #3b82f6 at position 0%.
- 4Set color stop 2: #8b5cf6 at position 100%.
- 5Color stops sorted by position: ['#3b82f6 0%', '#8b5cf6 100%'], joined: '#3b82f6 0%, #8b5cf6 100%'.
- 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:
- 1Select gradient type: Radial.
- 2Set shape to: ellipse.
- 3Set position to: center.
- 4Set color stop 1: #f97316 at position 0%.
- 5Set color stop 2: #ec4899 at position 100%.
- 6Color stops string: '#f97316 0%, #ec4899 100%'.
- 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:
- 1Select gradient type: Conic.
- 2Set the angle slider to 0 degrees.
- 3Set position to: center.
- 4Set color stop 1: #06b6d4 at position 0%.
- 5Set color stop 2: #3b82f6 at position 100%.
- 6Color stops string: '#06b6d4 0%, #3b82f6 100%'.
- 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:
- 1Select gradient type: Linear.
- 2Set angle to 135 degrees.
- 3Set color stop 1: #8b5cf6 at 0%.
- 4Set color stop 2: #6366f1 at 50%.
- 5Set color stop 3: #ec4899 at 100%.
- 6Stops sorted and joined: '#8b5cf6 0%, #6366f1 50%, #ec4899 100%'.
- 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
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.
Formula Source: Standard Mathematical References
by Various