Eskillsfy

Home / Blog / Web and CSS

Web and CSS · 23 Nov 2026

CSS Gradient Generator: how it works and how to build one

Design linear, radial and conic gradients and copy the CSS. This guide explains what happens behind the button and shows the code, so you can build your own.

What it does

Add color stops, drag positions, set the angle or shape, and see a live preview. Copy the CSS background rule or download a PNG. Presets give you a starting point.

When to use it

  • Hero backgrounds
  • Buttons and cards
  • Social images

How to use it

  1. Pick a type and preset.
  2. Change colors, stops and angle.
  3. Copy the CSS or download a PNG.

Try it free in your browser, nothing is uploaded: https://eskillsfy.com/tools/css-gradient-generator

How it works

A CSS gradient is an image the browser draws from a list of color stops. linear-gradient follows an angle, radial-gradient spreads from a center, and conic-gradient sweeps around a point like a pie chart.

The tool builds the CSS string from the stops and also draws the same gradient on a canvas (createLinearGradient, createRadialGradient, createConicGradient) for the PNG download.

Build it yourself

Here is the core of the tool. It has no dependencies unless noted, so you can paste it into any TypeScript or JavaScript project.

gradient.ts (ts)

type Stop = { color: string; pos: number };

export const gradientCss = (type: "linear" | "radial" | "conic", angle: number, stops: Stop[]) => {
  const list = [...stops].sort((a, b) => a.pos - b.pos).map((s) => `${s.color} ${s.pos}%`).join(", ");
  return type === "linear" ? `linear-gradient(${angle}deg, ${list})`
    : type === "radial" ? `radial-gradient(circle, ${list})`
    : `conic-gradient(from ${angle}deg, ${list})`;
};

// Fallback for very old browsers: a solid color first
// background: #f3d9b1; background: linear-gradient(135deg, #f3d9b1 0%, #5b3a63 100%);

Make it production-ready

  • Let users drag stops on a bar instead of sliders.
  • Add a ‘copy as Tailwind’ option.

Questions

Do gradients work in all browsers?

Linear and radial gradients work everywhere. Conic gradients work in all current browsers.

Try the CSS Gradient Generator

Free, runs in your browser, nothing is uploaded.

Open it
Keep reading

More in Web and CSS

All posts