CSS Gradient Generator
Build linear gradients visually. Pick colors, set direction, and copy the CSS.
Live PreviewRelated Tools
What is a CSS Gradient?
CSS gradients render smooth color transitions directly in the browser — no image files, no extra HTTP requests, no size penalty for high-DPI displays. They were standardized in CSS Image Values Module Level 3 (W3C, 2014) and are supported in all browsers since IE10. Modern gradients support unlimited color stops, transparency, hard color stops (sharp lines), and gradient color spaces (CSS Color Module Level 4).
Three gradient types
- linear-gradient() — straight-line transitions (vertical, horizontal, diagonal)
- radial-gradient() — radiating from a center point (circle or ellipse)
- conic-gradient() — rotating around a center point (used for pie charts, color wheels)
All three have repeating-* variants (repeating-linear-gradient, etc.) for repeating patterns like stripes, plaid, or checkerboards.
Why gradients beat images
For solid color transitions, CSS gradients are infinitely smaller, infinitely scalable, and instantly customizable. A 1MB hero image with a color gradient becomes 50 bytes of CSS. They render at any resolution without aliasing, animate smoothly, and respect accessibility preferences (reduced motion). For UI design in 2026, gradients are the default; PNG backgrounds are the exception.
How to Use
- Pick two or more colors using the color pickers, or click a preset for an instant start.
- Select a direction (top, right, etc.) or enter a custom angle in degrees (0deg = bottom, 90deg = right, 180deg = top).
- The live preview updates as you change colors and angles. The CSS code is shown below the preview.
- Click Add Color to add up to 5 color stops. Drag stops to reposition along the gradient line.
- Click Copy to copy the CSS to your clipboard. Paste into your stylesheet's
backgroundproperty.
CSS Gradient Syntax
linear-gradient
/* Direction keyword */ background: linear-gradient(to right, #ff0000, #0000ff); /* Specific angle (0deg = up, 90deg = right) */ background: linear-gradient(45deg, red, blue); /* Multi-stop with positions */ background: linear-gradient( to bottom, red 0%, yellow 50%, green 100% ); /* Hard color stops (no gradient) */ background: linear-gradient( to right, red 50%, blue 50% );
radial-gradient
/* Default (ellipse to corners) */ background: radial-gradient(red, blue); /* Circle from a position */ background: radial-gradient(circle at top right, red, blue); /* Sized */ background: radial-gradient( circle 200px at center, yellow, red );
conic-gradient
/* Color wheel */ background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red); /* Pie chart (3 slices) */ background: conic-gradient( red 0deg 120deg, blue 120deg 240deg, green 240deg 360deg );
Modern: gradient color spaces (CSS Color 4)
/* OKLCH gives perceptually uniform interpolation */ background: linear-gradient( in oklch, red, blue ); /* Compare to default sRGB — looks muddy in the middle */ background: linear-gradient(red, blue);
OKLCH/OKLAB color spaces avoid the muddy gray midpoint that sRGB gradients produce. Supported in all modern browsers since 2023.
Gradient Design Tips
1. Use 2–3 colors max
Most professional gradients use 2 colors with similar hues (analogous palettes) or one color with varying lightness. 4+ colors usually look chaotic. Stripe.com, Linear.app, Vercel.com — all use simple 2-stop gradients in their hero sections.
2. Avoid muddy midpoints
A red-to-blue gradient in sRGB passes through ugly gray in the middle. Solutions: (1) use in oklch for perceptually uniform mixing, or (2) add a vibrant midpoint color (red, purple, blue) so the path stays saturated.
3. Use opacity for depth
Layer multiple gradients with transparency for depth:
background: linear-gradient(135deg, rgba(255,0,150,.4), transparent), linear-gradient(45deg, rgba(0,150,255,.4), transparent), #1a1a2e;
4. Mesh gradients (multi-radial)
Stack multiple radial gradients at different positions for the trendy "mesh gradient" look popular in 2024+ UI:
background: radial-gradient(at 20% 30%, hsl(20, 80%, 60%), transparent), radial-gradient(at 80% 70%, hsl(280, 80%, 60%), transparent), hsl(220, 50%, 30%);
5. Use HSL for variations
HSL (Hue, Saturation, Lightness) is easier to manipulate than HEX. To create a gradient between similar shades: hsl(220, 80%, 50%) → hsl(220, 80%, 70%) — same hue, lighter version. OKLCH is even better for perceptual uniformity.
FAQ
Do I need the -webkit- prefix?
Not for any browser shipped after 2017. The unprefixed linear-gradient() works in Chrome, Safari, Firefox, Edge, and all mobile browsers. The -webkit- prefix only matters for very old Safari (<7) and very old Android Browser. Just use the unprefixed version.
Can I add more than 2 colors?
Yes — CSS gradients support unlimited color stops. This tool's UI allows up to 5 (anything more is rarely useful). Each color can have an explicit position (red 0%, yellow 30%, green 100%) or be evenly distributed.
What's the angle convention?
CSS uses 0deg = up (gradient goes from bottom to top), then clockwise: 90deg = right, 180deg = down, 270deg = left. Direction keywords (to top, to right, etc.) are equivalent and often clearer.
Can I animate gradients?
Not directly — CSS can't animate background-image with transition. Workarounds: animate background-position on a large gradient, use @property to register custom CSS variables with type <color>, or use SVG gradients with SMIL.
Why does my gradient look banded on dark colors?
Color banding happens when 8-bit color depth (256 levels per channel) can't represent smooth transitions between similar dark colors. Solutions: add subtle noise (CSS gradient + SVG noise overlay), use HDR with color() function (limited support), or target media queries for high-bit-depth displays.
Are gradients accessible?
They can be — but text on top of gradients often fails contrast checks. WCAG requires 4.5:1 contrast ratio for normal text. Test the lightest and darkest points of your gradient against your text color, not just the center.
⚠️ Reference Only
Output is generated based on your input and is provided for reference. Results may vary depending on your specific use case, edge cases, or environment-specific behavior. We do not guarantee accuracy of conversions, validations, or computed values.
Always verify critical outputs against official documentation or production environments. We are not responsible for any decisions or losses based on these tool results.
📖 Related Guides
UUID v4 vs ULID — Which to Choose?
Compare UUID v4 and ULID for distributed systems. Performance, sortability, and use cases.
Cron Expression Cheatsheet
Cron syntax reference with common patterns. Quartz vs Linux cron differences.
JWT Anatomy — Header, Payload, Signature
Understand JWT structure, claims, and signing algorithms. Security best practices.