# CSS gradient generator

Build a CSS linear, radial or conic gradient from a list of colour stops, with an SVG preview.

- Endpoint: `POST https://setget.net/v1/tools/css-gradient` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `css-gradient`
- Page: https://setget.net/tools/css-gradient

## Inputs

- `stops` (required, array): Two or more colours in order. Add a position to any of them, as in "#ff0000 25%".
- `type` (optional, string, one of `linear`, `radial`, `conic`, default `"linear"`): Kind of gradient.
- `angle` (optional, number, range -3600..3600): Angle in degrees. For linear, 0 points up and 90 points right (default 180). For conic, the starting angle (default 0).
- `direction` (optional, string): For linear gradients, a direction such as "to right" or "to bottom left" instead of an angle.
- `shape` (optional, string, one of `ellipse`, `circle`, default `"ellipse"`): For radial gradients, the shape.

## Example 1

```json
{"input":{"stops":["#ff0000","#0000ff"],"angle":90}}
```

Result:

```json
{"css":"linear-gradient(90deg, #ff0000, #0000ff)","declaration":"background: linear-gradient(90deg, #ff0000, #0000ff);","stops":[{"color":"#ff0000","position":0},{"color":"#0000ff","position":100}],"svg":"<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"120\" height=\"120\" viewBox=\"0 0 120 120\"><defs><linearGradient id=\"g\" x1=\"0\" y1=\"0.5\" x2=\"1\" y2=\"0.5\"><stop offset=\"0%\" stop-color=\"#ff0000\"/><stop offset=\"100%\" stop-color=\"#0000ff\"/></linearGradient></defs><rect width=\"120\" height=\"120\" fill=\"url(#g)\"/></svg>"}
```

## Example 2: Radial with a positioned stop

```json
{"input":{"stops":["gold","tomato 30%","rebeccapurple"],"type":"radial","shape":"circle"}}
```

Result:

```json
{"css":"radial-gradient(circle, #ffd700, #ff6347 30%, #663399)","declaration":"background: radial-gradient(circle, #ffd700, #ff6347 30%, #663399);","stops":[{"color":"#ffd700","position":0},{"color":"#ff6347","position":30},{"color":"#663399","position":100}]}
```

**Which colour formats can I type?** Hex (#rgb, #rrggbb, #rrggbbaa), rgb() and rgba(), hsl() and hsla(), hwb(), oklab(), oklch(), and any of the 148 CSS colour names such as "rebeccapurple".

**Which way does the angle point?** As in CSS: 0deg runs bottom to top, 90deg left to right, 180deg top to bottom.

**Where do stops without a position go?** The first is at 0%, the last at 100%, and the rest are spread evenly between their neighbours, exactly as browsers do.

**Why is there no SVG for radial and conic?** The preview is only made for linear gradients. SVG has no conic gradient, and its radial one is sized differently from CSS.
