Mentioned in this article
Free Online Tool: Try it now →
Introduction to CSS Gradients
CSS gradients let you create smooth transitions between two or more colors — no image files needed. They're resolution-independent, infinitely scalable, and reduce HTTP requests compared to using raster images.
CSS supports three types of gradients:
- Linear gradients: Colors transition along a straight line.
- Radial gradients: Colors radiate outward from a center point.
- Conic gradients: Colors rotate around a center point (like a pie chart).
Linear Gradients — Syntax and Examples
Basic syntax:
background: linear-gradient(direction, color1, color2, ...);
Simple Top-to-Bottom Gradient
background: linear-gradient(to bottom, #667eea, #764ba2);
Diagonal Gradient with Angle
background: linear-gradient(135deg, #f093fb, #f5576c);
Multi-Color Gradient with Color Stops
background: linear-gradient(to right, #4facfe 0%, #00f2fe 100%);
Radial Gradients — Syntax and Examples
background: radial-gradient(shape size at position, color1, color2);
Simple Circular Gradient
background: radial-gradient(circle, #a18cd1, #fbc2eb);
Elliptical Gradient at Custom Position
background: radial-gradient(ellipse at top, #e0c3fc, #8ec5fc);
Conic Gradients — The Modern Gradient
background: conic-gradient(from angle at position, color1, color2);
Simple Conic Gradient (Pie Effect)
background: conic-gradient(#ff6b6b 0deg 90deg, #feca57 90deg 180deg, #48dbfb 180deg 270deg, #ff9ff3 270deg 360deg);
How to Use the CSS Gradient Generator
Rather than writing gradient code by hand, use RapidKit's CSS Gradient Generator:
- Choose your gradient type (linear, radial, or conic).
- Pick your colors using the color pickers.
- Add multiple color stops and position them visually.
- Adjust the angle or direction.
- Copy the generated CSS code with one click.
Gradient Best Practices
- Use HSL colors for harmonious gradients: Rotating the hue value while keeping saturation and lightness consistent produces naturally beautiful gradients.
- Avoid "gray dead zone": Gradients going through gray (e.g., red to blue through white) look muddy. Add an intermediate color stop to route around it.
- Test in dark mode: Gradients that look great in light mode can look washed out in dark mode.
- Subtle gradients ≠ simple: A 5-10% lightness difference can add depth without being obvious.
Performance Notes
CSS gradients are rendered by the GPU and are extremely performant. They are always preferred over gradient images for:
- Backgrounds that need to scale to any size
- Hover states and transitions
- Animated gradients (using CSS custom properties and transitions)