Linear Gradient Generator
Generate beautiful CSS linear gradients visually. Add color stops, adjust angles, preview in real-time, and copy production-ready CSS code.
About
CSS linear gradients interpolate color values along a directional axis defined by an angle θ in degrees. A misconfigured gradient - wrong stop positions, clashing hues, or banding artifacts from insufficient color stops - produces unprofessional results that degrade perceived quality of any interface. This tool computes the exact linear-gradient() declaration with unlimited color stops, each positioned at a percentage p along the gradient line from 0% to 100%. It renders a real-time Canvas preview at full resolution so you see exactly what the browser will paint.
The generator outputs copy-ready CSS. It handles edge cases: duplicate stop positions create hard color boundaries, a single stop produces a solid fill, and stops beyond 100% are clamped. Note: gradient rendering varies slightly between browsers at sub-pixel level. This tool targets the W3C CSS Image Values Level 3 specification. Pro Tip: for smooth gradients, keep perceptual distance between adjacent stops roughly equal in HSL lightness.
Formulas
A CSS linear gradient is defined by an angle and a series of color stops. The browser computes the gradient line through the center of the element at the specified angle, then interpolates colors between stops.
Where θ = rotation angle from vertical axis (0° = bottom to top). Ci = color value at stop i (HEX, RGB, or HSL). pi = position of stop i along the gradient line, 0% ≤ p ≤ 100%.
The gradient line length L for an element of width w and height h is:
Color interpolation between two adjacent stops uses linear interpolation in sRGB space per channel:
Where t = p − pipi+1 − pi is the normalized position between stops.
Reference Data
| Angle | Direction | CSS Keyword | Use Case |
|---|---|---|---|
| 0° | Bottom → Top | to top | Vertical fade-up backgrounds |
| 45° | Bottom-Left → Top-Right | to top right | Diagonal hero sections |
| 90° | Left → Right | to right | Horizontal progress bars |
| 135° | Top-Left → Bottom-Right | to bottom right | Card overlays |
| 180° | Top → Bottom | to bottom | Default gradient direction |
| 225° | Top-Right → Bottom-Left | to bottom left | Reverse diagonal overlays |
| 270° | Right → Left | to left | RTL interface accents |
| 315° | Bottom-Right → Top-Left | to top left | Decorative backgrounds |
| Common Gradient Presets | |||
| 135° | Warm Sunset | #FF6B6B → #FFA07A | Landing pages, CTAs |
| 90° | Ocean Breeze | #667eea → #764ba2 | SaaS headers |
| 45° | Fresh Mint | #00b09b → #96c93d | Health/eco themes |
| 180° | Cool Steel | #bdc3c7 → #2c3e50 | Corporate dashboards |
| 120° | Berry Smoothie | #e96443 → #904e95 | Creative portfolios |
| 60° | Peach Glow | #ffecd2 → #fcb69f | Soft UI backgrounds |
| 200° | Deep Space | #000428 → #004e92 | Dark mode hero sections |
| 90° | Lemon Drop | #f7ff00 → #db36a4 | Bold, playful accents |
| 135° | Northern Lights | #43cea2 → #185a9d | Teal-blue transitions |
| 270° | Lavender Haze | #c471f5 → #fa71cd | Feminine/artistic layouts |
Frequently Asked Questions
linear-gradient(90deg, red 50%, blue 50%) produces a clean split at the midpoint.linear-gradient with repeating-linear-gradient in the output CSS. Set your last color stop at a position less than 100% - for example, 20% - and the browser tiles the gradient five times across the element. This tool generates the stop values; you only need to swap the function name in your stylesheet.