CSS Gradient Generator
DesignGenerate linear and radial CSS gradient code instantly. Pick colours and direction, copy the background property — free, browser-based, no sign-up needed.
Reviewed by the thecalcu.com team · Last updated July 10, 2026
What is a CSS Gradient?
A CSS Gradient Generator builds the CSS background property declaration for linear, radial, and conic gradients, ready to copy and paste directly into a stylesheet, a Tailwind arbitrary value, or a CSS-in-JS string.
CSS gradients are one of the most widely used design elements in modern web interfaces: hero section backgrounds, card overlays, button fills, text colour effects, and decorative borders all commonly use gradient fills. The alternative, exporting a PNG gradient image from a design tool, produces a larger file, requires an HTTP request, looks blurry on high-density screens, and cannot be easily edited in code. A pure CSS gradient is a single property declaration, renders at any resolution, and can be changed by editing a hex code.
The generator covers the three gradient types available in CSS: linear (colour transitions along a straight line at any angle), radial (circular or elliptical transitions from a centre point), and conic (colour sweeps around a centre point). Each accepts two required colour stops and an optional mid-stop for three-colour gradients.
For generating colour values to use as gradient stops, the Colour Palette Generator produces harmonious multi-colour palettes from a base colour using colour theory rules. The Hex Color Generator converts between hex, RGB, and HSL formats, useful when you need to express a gradient stop in a specific colour notation.
Why Use a CSS Gradient Generator?
Writing gradient CSS by hand is straightforward for simple cases but quickly becomes tedious when you need to experiment with different directions, colour combinations, or stop positions. The generator eliminates the write-save-refresh cycle for the exploration phase: adjust colours and direction, see the exact CSS output, copy when satisfied.
The output is syntactically correct and uses the modern unprefixed linear-gradient() syntax, no -webkit-, -moz-, or -o- vendor prefixes, which have not been required since 2013. Copy-paste into any current project without modification.
Who Should Use This Generator?
Frontend developers building UI components who need gradient backgrounds, overlays, or fills. The generated declaration is production-ready CSS, no framework translation required.
Designers working in code who prototype directly in HTML/CSS and need to iterate quickly on gradient combinations without switching to a design tool.
Tailwind CSS developers who can use the generated gradient value as an arbitrary bg-[...] class or add it to tailwind.config.js as a custom background utility.
CSS learners who want to understand the syntax for the three gradient types, the generator makes the relationship between the inputs and the output declaration transparent.
What Insights Does the CSS Gradient Generator Give You?
Two outputs per generation:
CSS Declaration, the complete background: ...; property, ready to paste into any CSS rule. For example: background: linear-gradient(135deg, #2F6FED, #1A1A2E);
Gradient Value Only, just the function call without the property name, for use in contexts where you need to supply the value separately: Tailwind arbitrary values (bg-[linear-gradient(...)]), CSS custom properties (--hero-bg: linear-gradient(...)), or CSS-in-JS template strings.
How to use this CSS Gradient calculator
- Select the gradient type, Linear for directional colour transitions, Radial for circular fills, Conic for angular sweeps.
- Choose a direction, for Linear, select a cardinal direction or diagonal angle. For Radial and Conic, the direction field controls the conic start angle (Radial always emanates from the centre).
- Enter Colour 1, the start colour as a hex code,
rgb(),hsl(), or a named colour. - Enter Colour 2, the end colour in the same format.
- Optionally enter Colour 3, a mid-stop placed between Colour 1 and Colour 2. Leave blank for a two-stop gradient.
- Click Generate, the CSS Declaration and Gradient Value outputs appear immediately.
- Copy the CSS Declaration and paste it into your stylesheet, component, or design token.
Formula & Methodology
The generator constructs the gradient value by assembling the CSS gradient function from the selected inputs: Linear gradient:css background: linear-gradient(<direction>, <color1>, [<color3>,] <color2>);Radial gradient:css background: radial-gradient(circle, <color1>, [<color3>,] <color2>);Conic gradient:css background: conic-gradient(from <angle>, <color1>, [<color3>,] <color2>);The mid-stop (Colour 3), when provided, is placed between the two outer stops without an explicit percentage position, the browser places it at 50% by default. To override the position, edit the output directly:linear-gradient(to right, #2F6FED, #ffffff 30%, #1A1A2E). Direction reference for linear gradients: | Keyword | Equivalent angle | Effect | |---|---|---| |to right|90deg| Left → Right | |to bottom|180deg| Top → Bottom | |to left|270deg| Right → Left | |to top|0deg| Bottom → Top | |135deg| N/A | Top-left → Bottom-right | |45deg| N/A | Bottom-left → Top-right |
Frequently Asked Questions