CSS Gradient Generator
What This Tool Does
This CSS gradient generator builds linear-gradient and radial-gradient CSS values with a live preview. You can set multiple color stops, adjust the angle or position, and copy the final CSS code ready to paste into your stylesheet. Perfect for modern web design, buttons, hero sections, and card backgrounds.
Inputs Explained
- Gradient Type: Linear (along an angle) or Radial (from a center point).
- Angle: For linear gradients, 0-360 degrees. 0° = bottom-to-top, 90° = left-to-right.
- Color Stops: Two or more colors with optional position percentages.
- Preview: Live rectangle showing the current gradient.
How It Works
The tool constructs the CSS string from your inputs: linear-gradient(90deg, red 0%, blue 100%) or radial-gradient(circle at center, red, blue). It applies the same value to the preview box's background-image property in real time, so what you see is exactly what you'll copy.
Formula / Logic Used
Create linear and radial CSS gradients with live preview and copy-ready code.
CSS Code
Step-by-Step Example
Type: Linear, Angle: 90°
Colors: #2563eb at 0%, #0d9488 at 100%
Output CSS:
background: linear-gradient(90deg, #2563eb 0%, #0d9488 100%);
Add intermediate color stops (e.g., white at 50%) to create multi-color gradients. For radial gradients, select the shape and center position from the dropdown.
Use Cases
- Hero section backgrounds: Create eye-catching gradient backgrounds for landing pages.
- Button styling: Design modern CTA buttons with subtle color transitions.
- Card designs: Add gradient overlays to cards and panels for visual depth.
- Logo backgrounds: Test brand color combinations before finalizing designs.
- Dark mode themes: Design smooth gradient transitions for dark UI elements.
Assumptions and Limitations
- Generated CSS uses standard syntax supported in all modern browsers (IE11+, though IE has limited support).
- Very complex gradients with many stops may render differently on old mobile devices.
- Color stops should be in ascending order for predictable results.
- For conic-gradient support, use a dedicated tool — this generator handles linear and radial only.
CSS Gradient Generator Examples
Use the css gradient generator to test a background before pasting it into a stylesheet. A simple linear gradient looks like background: linear-gradient(90deg, #2563eb, #14b8a6);. A radial gradient looks like background: radial-gradient(circle, #ffffff, #94a3b8);.
Tone Generator CSS Gradient Generator
The tone generator css gradient generator wording usually means a softer color ramp. Pick one base color, then use a lighter tint and a deeper shade so buttons, cards, and banners feel related without turning the whole page into one flat color.
Frequently Asked Questions
How do I create a diagonal CSS gradient?
Use a directional keyword or angle in linear-gradient(). For example, background: linear-gradient(135deg, #ff7e5f, #feb47b); gives you a smooth top-left to bottom-right diagonal. Or use to bottom right instead of 135deg — they're equivalent and read more naturally. Other corners: to top left is 315deg, to top right is 45deg, to bottom left is 225deg. Our generator lets you drag the angle slider and see the result live, then copy production-ready CSS. Diagonal gradients add depth without the heaviness of a full background image.
How do I generate a gradient with three or more colors?
Just keep adding colour stops separated by commas: linear-gradient(90deg, red, yellow, green, blue). CSS spaces them evenly by default. Want control? Add explicit positions: linear-gradient(90deg, red 0%, yellow 30%, green 60%, blue 100%). You can stack as many stops as you like — sunsets and aurora effects often use 5 or 6. For really smooth multi-stop gradients, modern CSS also supports in oklch interpolation: linear-gradient(in oklch, red, blue), which avoids the muddy grey midpoint you sometimes get in sRGB. Our tool lets you add or remove stops with one click.
How do I create a smooth fade-to-transparent gradient?
Use rgba() or #RRGGBBAA and end with full transparency. A common pattern is linear-gradient(to bottom, rgba(0,0,0,0.7), rgba(0,0,0,0)); — perfect for image overlays where you want text on top to stay readable. Important tip: don't fade to plain transparent (which is rgba(0,0,0,0) — black with zero alpha). On some browsers it can produce a greyish band as it interpolates through black. Always fade to the same colour with alpha 0, like rgba(255,255,255,1) to rgba(255,255,255,0) for a white fade. That keeps the transition pure and pixel-clean.
What is the difference between background and background-image for gradients?
Functionally, gradients work in either property because gradients are technically images. But background is a shorthand that resets all the other background sub-properties (color, repeat, position, size, attachment) to their defaults. So if you set background: linear-gradient(...) after setting background-color: red, the red disappears. Using background-image: linear-gradient(...) only changes the image and leaves the rest alone. For most cases the shorthand is fine, but inside complex stacks or when layering a gradient over a fallback colour, prefer background-image to avoid surprise resets.
Why does my CSS gradient look banded or pixelated?
That visible "stripe" effect is colour banding, and it shows up when the gradient covers a wide area with too few perceptible colour steps in 8-bit sRGB. Three fixes that work: one, add subtle noise via a transparent PNG or SVG overlay (the classic trick); two, use modern linear-gradient(in oklch, ...) for smoother perceptual interpolation; three, reduce contrast between stops or add intermediate colour stops. Some monitors are also worse at showing gradients — test on retina and standard screens. Our generator output is browser-perfect, but the display matters too.
What is the difference between to right and 90deg in a CSS gradient?
They produce the same result — a horizontal left-to-right gradient. CSS lets you specify direction in two ways: by keyword (to right, to bottom, to top left) or by angle (90deg, 180deg, etc.). One thing trips people up: 0deg points up (to top), not right. So 90deg = to right, 180deg = to bottom, 270deg = to left. Keywords are easier to read and harder to get wrong; angles give you precision for non-axis-aligned gradients. Use whichever matches your design intent — both compile identically in the browser.
How do I copy ready-to-use gradient CSS code?
Right next to the live preview on our generator, there's a "Copy CSS" button that grabs the full property-value pair, ready to paste into your stylesheet. We include the standard background: declaration plus a fallback solid colour as a comment for older browsers. If you want SCSS variables or Tailwind arbitrary values like bg-[linear-gradient(...)], toggle the format dropdown. Quick tip: paste it inside a class selector, not inline on the element, so you can reuse the gradient across your site without copy-pasting hex codes everywhere.
Sources and References
- MDN — linear-gradient — Complete reference for CSS linear-gradient syntax.
- MDN — radial-gradient — Complete reference for CSS radial-gradient syntax.
- CSS Images Module Level 4 — W3C specification including conic-gradient and modern features.
- Can I Use — CSS Gradients — Browser compatibility for gradient features.