CSS Gradient Generator — Linear & Radial Gradient Builder
Visually create linear and radial CSS gradients. Adjust angle, colors, and color stops with live preview.
About CSS Gradient Generator — Linear & Radial Gradient Builder
CSS Gradient Generator lets you build linear, radial, and conic CSS gradients visually with a live preview. Generate clean CSS background-image gradient code ready to paste into any stylesheet.
How to Use
- 1Choose the gradient type (Linear, Radial, or Conic) and set the angle or position.
- 2Add color stops and adjust their positions and opacity using the visual editor.
- 3Copy the generated CSS code and paste it into your stylesheet.
Features
- Supports Linear, Radial, and Conic gradient types
- Live visual preview with instant code generation
- Add multiple color stops with custom positions
- No external libraries needed — outputs pure CSS
CSS Gradient Fundamentals
A CSS gradient creates a smooth color transition entirely in the browser — no image files required. Gradients are part of the CSS Images specification and can be used anywhere an image value is accepted: background, background-image, border-image, list-style-image, and more. They are resolution-independent and reduce HTTP requests compared to raster image gradients.
linear-gradient()
Creates a gradient along a straight line. You define a direction (e.g., "to right", "45deg") and two or more color stops. Syntax: linear-gradient(direction, color-stop1, color-stop2, ...). The direction defaults to "to bottom" if omitted. Example: background: linear-gradient(to right, #6366f1, #22c55e) — produces a left-to-right indigo-to-green transition.
radial-gradient()
Creates a gradient that radiates outward from a center point in a circular or elliptical shape. Define the shape (circle or ellipse), size keyword (closest-side, farthest-corner, etc.), center position, and color stops. Example: radial-gradient(circle at center, #6366f1, #1e1b4b). Ideal for spotlight effects, glowing buttons, and depth cues.
conic-gradient()
Creates a gradient that rotates around a center point, like a color wheel. Available in all modern browsers since 2021. Syntax: conic-gradient(from angle at position, color-stop, ...). Example: conic-gradient(red, yellow, green, blue, red). Perfect for pie charts, donut charts, and circular progress indicators — all in pure CSS.
Advanced CSS Gradient Techniques
Beyond basic color transitions, CSS gradients support advanced patterns including hard edges, repetition, and text fills. Mastering these unlocks complex visual effects with no images or JavaScript.
Hard Stops and Repeating Gradients
A hard stop is created by placing two color stops at the same position: linear-gradient(to right, blue 50%, red 50%) creates a sharp half-and-half split. Repeating variants — repeating-linear-gradient(), repeating-radial-gradient() — tile the pattern, enabling stripes, checkerboards, and candy-cane effects entirely in CSS.
Gradient Text Effect
To apply a gradient to text, set background: gradient(...) on the element, then add -webkit-background-clip: text and -webkit-text-fill-color: transparent. This clips the gradient to the text shape. Example: background: linear-gradient(90deg, #6366f1, #22c55e); -webkit-background-clip: text; -webkit-text-fill-color: transparent. Works in all modern browsers; include both -webkit- and unprefixed versions.
Layering Multiple Gradients
You can stack multiple gradients and background images on a single element by separating them with commas in the background-image property. Layers are rendered front-to-back (left-to-right in the declaration). This enables complex compositions: a radial gradient overlay on a linear gradient base, for example.
Performance, Accessibility, and Browser Support
CSS gradients are GPU-accelerated and more performant than background images for static designs. However, there are important considerations around animation, accessibility, and progressive enhancement.
Browser Support
linear-gradient and radial-gradient are supported in 99%+ of browsers. conic-gradient covers 95%+ (Chrome 69+, Firefox 83+, Safari 12.1+). Always declare a solid background-color fallback before the gradient: background-color: #6366f1; background-image: linear-gradient(...). Browsers that do not support the gradient fall back to the solid color gracefully.
Animation Performance
Avoid transitioning gradient property values directly — the browser repaints the entire element on every frame, causing jank on mobile devices. Instead, animate the opacity of a pseudo-element or overlay div that holds the gradient. Alternatively, use the CSS @property rule to register and animate a custom property with hardware acceleration (supported in Chromium browsers).
Accessibility and Contrast
Text on gradients presents a contrast challenge: a color that passes WCAG AA at one end may fail at the other. Test contrast at both the lightest and darkest point of the gradient against the text color. WCAG 2.1 AA requires at least 4.5:1 for normal text. For long-form text, use a solid or semi-transparent background instead of placing text directly over a gradient.
FAQ
- Does the generated CSS work in all browsers?
- Linear and radial gradients have near-universal support (99%+). Conic gradients are supported in Chrome 69+, Firefox 83+, Safari 12.1+, and Edge 79+ — covering 95%+ of users as of 2025. Always provide a background-color fallback before the gradient declaration for older browsers.
- Can I make a transparent gradient?
- Yes. Use rgba() or hsla() values for your color stops. For example: linear-gradient(to right, rgba(99,102,241,1), rgba(99,102,241,0)) fades from solid indigo to fully transparent.
- How do I use the gradient as a background?
- Apply the generated CSS to your element's background or background-image property: background: linear-gradient(to right, #6366f1, #22c55e). For full-page backgrounds, also set background-attachment: fixed to prevent scrolling artifacts.
- Can I apply a CSS gradient to text?
- Yes. Set background to the gradient, then add -webkit-background-clip: text and -webkit-text-fill-color: transparent (use background-clip: text for Firefox). This clips the gradient to the text shape. Works in all modern browsers.
- What is the difference between linear-gradient and background-image?
- CSS gradients are treated as images, so they are set via background-image (or the background shorthand). You can layer multiple gradients by separating them with commas: background-image: linear-gradient(...), radial-gradient(...).
- Can I animate a CSS gradient?
- Direct CSS transitions on gradients cause full repaints every frame — avoid this for performance. Instead, animate the opacity of a gradient overlay element, or use the CSS @property rule to register a custom property and animate it with hardware acceleration (Chromium-based browsers).
- How do I create a striped background with CSS gradients?
- Use repeating-linear-gradient with hard stops: background: repeating-linear-gradient(45deg, #6366f1, #6366f1 10px, transparent 10px, transparent 20px). Hard stops (two color stops at the same position) create sharp edges instead of blended transitions.
Found a bug or something not working as expected?
Report a bug →