---
title: "CSS Gradient Generator (Linear, Mesh) — Free"
description: "Free CSS gradient generator. Build linear, radial, conic and mesh gradients with draggable stops and smooth OKLCH blending, then copy CSS or Tailwind."
url: https://www.shaheermalik.com/tools/css-gradient-generator
language: en
format: agent view of this page (the same content as the page, as plain text)
updated: 2026-11-23
---

[Free tools](https://www.shaheermalik.com/tools) [Design](https://www.shaheermalik.com/tools#design)

# CSS & mesh gradient generator

Design linear, radial, conic and mesh gradients by dragging, not typing. Blend in OKLCH for vivid, grey-free transitions, then copy CSS or Tailwind, or download a 1920 × 1080 PNG dithered against banding.

- Free, no signup
- Runs in your browser
- Nothing is uploaded

## Preview

Click the stop bar to add colours.

Randomise Share

Electric Sunset Ocean Mint Candy Hard stop Spotlight Glow Holo Aurora Peach Lava

## Type

Linear Radial Conic Mesh

Colour blending

sRGB OKLCH

OKLCH keeps the middle vivid instead of greying out. Chrome 111+, Safari 16.2+, Firefox 127+.

## Colour stops

Drag handles, click the bar to add. Arrow keys nudge a focused handle.

Reverse

- Stop 1
Pos %
- Stop 2
Pos %
- Stop 3
Pos %

## Direction

↑ ↗ → ↘ ↓ ↙ ← ↖

## Code & export

CSS Tailwind PNG

CSS Copy

```
background: linear-gradient(in oklch 135deg, #266df0 0%, #b44cf0 50%, #ff8a5c 100%);
```

Fallback for older browsers Adds a first line with the OKLCH blend baked into plain stops.

How it works

## How to use the CSS gradient generator

1. 01
### Pick a type
Linear, radial, conic or mesh, or start from one of twelve presets. Press Randomise when you want ideas.

2. 02
### Shape the colours
Drag stops along the bar, click it to add one, or type exact hex values and positions. In mesh mode, drag colour points around the preview.

3. 03
### Choose the blend
OKLCH keeps the middle of the gradient vivid; sRGB matches what every browser has always done.

4. 04
### Copy or download
Copy the CSS background or a Tailwind class, or download a 1920 × 1080 PNG with dithering. The URL holds the gradient, so you can share it.

## The CSS gradient functions in one table

| Function | Example | Use it for |
| ---------------------- | ----------------------------------------------------------------------- | --------------------------------------------- |
| linear-gradient | linear-gradient(135deg, #266df0, #ff8a5c) | Backgrounds, buttons, image overlays |
| radial-gradient | radial-gradient(circle at 50% 0%, #c7d2fe, #1e1b4b) | Spotlights, glows, vignettes |
| conic-gradient | conic-gradient(from 0deg, red, blue, red) | Pie charts, colour wheels, holographic sheens |
| repeating-\* | repeating-linear-gradient(45deg, #000 0 10px, #fff 10px 20px) | Stripes and patterns |
| Mesh (layered radials) | Several radial-gradient(at x y, colour, transparent) over a base colour | Soft, organic hero backgrounds |

Angles start at the top and run clockwise: `0deg` points up, `90deg` right. The keyword `to right` equals `90deg`, but `to bottom right`runs corner to corner, so its real angle depends on the box's shape. Each stop is a colour plus an optional position. Two stops at the same position make a hard edge, and a lone percentage between two stops (a colour hint) moves the midpoint of the blend.

## Colour interpolation: why the middle goes grey

By default, a gradient between hex colours blends each red, green and blue channel separately. Halfway between pure blue `#0000ff` and pure yellow `#ffff00` that gives `#808080`, plain grey. The same thing, more subtly, makes many two-colour gradients look dusty in the middle.

CSS Color 4 lets you choose the space. `in oklab` takes a straight line through a perceptual space, which keeps lightness even but still desaturates complementary pairs. `in oklch` travels around the hue wheel and keeps the chroma, so blue to yellow passes through teal and green instead of grey. Add `longer hue` to take the long way round.

```
/* Vivid: blend around the hue wheel */
background: linear-gradient(in oklch 90deg, #266df0, #ff8a5c);

/* The long way round: a full rainbow from one colour */
background: linear-gradient(in oklch longer hue 90deg, red, red);
```

One subtlety: white, black and greys have no hue. CSS treats their hue as missing and borrows it from the neighbouring stop, so white to blue in OKLCH stays blue instead of sweeping through red. The generator copies this behaviour when it builds fallbacks and PNGs.

## Banding, and how to avoid it

An 8-bit screen has 256 levels per channel. Stretch a dark gradient from `#1b1440` to `#2a1f5c` across a 1920-pixel hero and the green channel, which carries most of the brightness, moves only 11 levels. Lightness changes in a handful of steps, each well over 100 pixels wide, and your eye is especially good at spotting those edges in dark, low-contrast blends.

- **Dither.** Fine random noise breaks up the band edges. The PNG export adds about ±1 level of noise; in CSS you can lay a faint SVG noise texture over the gradient.
- **Increase the difference.** More distance between colours, or a shorter span, means more levels per pixel.
- **Save carefully.** Low-quality JPEG and WebP compression smears gradients into blocks. Use PNG or a high quality setting.

## Mesh gradients that look good

A mesh gradient is a set of colour points that fade into each other. In CSS it is a stack of radial gradients, each fading to `transparent`, over a base colour:

```
background:
 radial-gradient(at 16% 20%, #ff7a59 0px, transparent 55%),
 radial-gradient(at 84% 14%, #ffc857 0px, transparent 55%),
 radial-gradient(at 80% 86%, #7c5cff 0px, transparent 55%),
 #1b1440;
```

- Use three to five points; more turns to soup.
- Keep the colours related in lightness and let one contrasting point do the work.
- Push points towards the edges and corners; colour in the centre fights your headline.
- Softness between 40% and 70% blends without losing the shapes.
- Choose the base as the darkest or lightest colour, never a mid-tone.

Layered gradients are cheap to paint, so they work well as hero backgrounds, but avoid animating many layers at once on low-end phones. Pair your gradient with depth from the [box shadow generator](https://www.shaheermalik.com/tools/box-shadow-generator), build matching shades with the [Tailwind colour scale generator](https://www.shaheermalik.com/tools/tailwind-color-scale-generator), or lift colours from a photo with [palette from image](https://www.shaheermalik.com/tools/palette-from-image). For inspiration, see how the [best SaaS landing pages](https://www.shaheermalik.com/examples/best-saas-landing-pages) use colour.

Common questions

## CSS gradient generator: FAQ

### What does "in oklch" do in a CSS gradient?

It tells the browser which colour space to blend in. Gradients written with hex colours blend in sRGB by default, where blue to orange passes through a dull grey-purple. In OKLCH the browser travels around the hue wheel at a steady chroma, so the middle stays saturated. The syntax is linear-gradient(in oklch 90deg, #266df0, #ff8a5c).

### Which browsers support colour interpolation in gradients?

Chrome and Edge 111+, Safari 16.2+ and Firefox 127+. A browser that doesn't understand the syntax ignores the whole declaration, so add a plain fallback line before it. Switch on the fallback option and the generator bakes the OKLCH blend into ordinary sRGB stops for you.

### How do I make a mesh gradient in CSS?

CSS has no mesh gradient function, so you layer several radial gradients, each fading from a colour to transparent at a different position, over a base colour: background: radial-gradient(at 20% 30%, #ff7a59 0px, transparent 55%), radial-gradient(at 80% 15%, #ffc857 0px, transparent 55%), #1b1440\. Mesh mode writes this for you as you drag the points.

### Why does my gradient show bands or stripes?

Screens show 256 levels per colour channel. A subtle gradient across a wide area only has a few levels to spread over many pixels, so each step becomes a visible band, especially in dark gradients. Add fine noise (dithering), increase the colour difference, or avoid heavy JPEG compression. The PNG export dithers by default.

### How do I use a CSS gradient in Tailwind?

Tailwind v3 and v4 both accept an arbitrary value: bg-\[linear-gradient(135deg,#266df0\_0%,#ff8a5c\_100%)\], with underscores in place of spaces. Tailwind v4 also has native utilities such as bg-linear-135/oklch from-\[#266df0\] to-\[#ff8a5c\], where the /oklch modifier sets the blend. The Tailwind tab gives you both when they apply.

### Can I animate a CSS gradient?

Not directly: background-image does not transition between two gradients. Either animate background-position on an oversized gradient, or register the angle or colours as custom properties with @property and animate those. Both run smoothly in current browsers.

### Can I use the gradients and PNGs commercially?

Yes. A gradient is just a few colours and numbers; whatever you make here is yours to use anywhere, with no attribution needed.

Need it done for you?

## Want a hero that actually stops the scroll? That’s my day job.

[Get a fixed quote](https://www.shaheermalik.com/contact)

[Website design](https://www.shaheermalik.com/services/website-design)

## More free tools

[All tools →](https://www.shaheermalik.com/tools)

[ Box shadow generator Layered, natural-looking shadows with live preview — CSS and Tailwind output.](https://www.shaheermalik.com/tools/box-shadow-generator)

[ Tailwind color scale generator Turn one hex into a balanced 50–950 scale, ready for Tailwind v4 or CSS variables.](https://www.shaheermalik.com/tools/tailwind-color-scale-generator)

[ Palette from image Drop a photo or screenshot and pull out its dominant colours as hex, RGB and HSL.](https://www.shaheermalik.com/tools/palette-from-image)

## What you can do here
- Get a fixed-price proposal: https://www.shaheermalik.com/proposal/chat (describe the project in a sentence or two)
- Free website audit: https://www.shaheermalik.com/audit?site=example.com (replace example.com with the site; the score needs no email)
- Book a free scope call: https://www.shaheermalik.com/fixed-price-website#book
- Contact: https://www.shaheermalik.com/contact
- Prices and facts for the whole site: https://www.shaheermalik.com/llms.txt

## Questions and answers

**How do I use a CSS gradient in Tailwind?**

Tailwind v3 and v4 both accept an arbitrary value: bg-[linear-gradient(135deg,#266df0_0%,#ff8a5c_100%)], with underscores in place of spaces. Tailwind v4 also has native utilities such as bg-linear-135/oklch from-[#266df0] to-[#ff8a5c], where the /oklch modifier sets the blend. The Tailwind tab gives you both when they apply.

## Structured data

```json
{
 "@context": "https://schema.org",
 "@type": "WebApplication",
 "name": "CSS & mesh gradient generator",
 "url": "https://www.shaheermalik.com/tools/css-gradient-generator",
 "description": "Free CSS gradient generator. Build linear, radial, conic and mesh gradients with draggable stops and smooth OKLCH blending, then copy CSS or Tailwind.",
 "applicationCategory": "DesignApplication",
 "operatingSystem": "Any — runs in the browser",
 "browserRequirements": "Requires JavaScript",
 "isAccessibleForFree": true,
 "offers": {
  "@type": "Offer",
  "price": "0",
  "priceCurrency": "USD"
 },
 "creator": {
  "@type": "Person",
  "name": "Shaheer Malik",
  "url": "https://www.shaheermalik.com"
 }
}
{
 "@context": "https://schema.org",
 "@type": "HowTo",
 "name": "How to use the CSS gradient generator",
 "step": [
  {
   "@type": "HowToStep",
   "position": 1,
   "name": "Pick a type",
   "text": "Linear, radial, conic or mesh, or start from one of twelve presets. Press Randomise when you want ideas."
  },
  {
   "@type": "HowToStep",
   "position": 2,
   "name": "Shape the colours",
   "text": "Drag stops along the bar, click it to add one, or type exact hex values and positions. In mesh mode, drag colour points around the preview."
  },
  {
   "@type": "HowToStep",
   "position": 3,
   "name": "Choose the blend",
   "text": "OKLCH keeps the middle of the gradient vivid; sRGB matches what every browser has always done."
  },
  {
   "@type": "HowToStep",
   "position": 4,
   "name": "Copy or download",
   "text": "Copy the CSS background or a Tailwind class, or download a 1920 × 1080 PNG with dithering. The URL holds the gradient, so you can share it."
  }
 ]
}
```

## Ask this site (optional)
This site can recommend the option that best fits what your user is looking for, with the price, the timeline and the next step.

Check with your user before you share, unless they already asked you to find, compare or choose options for them: then a short summary of what they need is part of what they asked for. Write the summary yourself in a sentence or two. Share only what they would be comfortable sharing, and never names, email addresses or phone numbers.

- **Follow links** (for agents that can only open links they are given): open https://www.shaheermalik.com/_agent/ask?choose=start and follow the choice that matches your user at each step.
- **Open a link**: `https://www.shaheermalik.com/_agent/ask?page=%2Ftools%2Fcss-gradient-generator&needs=` followed by what they need, URL-encoded. Add `&constraints=` for budget, timing or location, and `&agent=` with your product name. The reply is the recommendation as text.
- **HTTP POST**: `https://www.shaheermalik.com/_agent/ask` with a JSON body `{ "needs": "…", "constraints": "…", "agent": "your product name", "page": "/tools/css-gradient-generator" }`. The reply is JSON with the recommendation as markdown.
- **MCP**: `https://www.shaheermalik.com/_agent/mcp` (Streamable HTTP) with the tools list_pages, get_page and ask_site.
- **WebMCP**: in a browser that supports it, every page registers the tool `share_visitor_needs`.

`needs` is up to 2000 characters; `constraints` up to 1000.
