Skip to content

How to build a gradient and read the declaration you copy

The workbench starts as linear-gradient(135deg, #0f9d66 0%, #2d5bff 55%, #7c3aed 100%). The preview paints that declaration and the output panel prints it, so the code you copy is the gradient you were looking at.

Every control has a measured limit: the angle is held between 0 and 360 degrees, stop positions between 0 and 100 percent, and the stop list between two and eight entries. A value typed outside those bounds is written back to the limit when you leave the field instead of being used silently by the preview.

  1. Choose the type. Linear and conic read the angle field; radial-gradient() has no angle, so the field is locked while Radial is selected.
  2. Set the angle for linear or conic. Type 0 to 360; 720 is stored as 360 and -45 as 0, and leaving the field empty restores the last valid angle.
  3. Edit each stop: pick a colour or type a six-digit HEX value, then set its position from 0 to 100. Positions are kept to one decimal, so 3.75 is stored as 3.8 and printed as 3.8%.
  4. Add a stop to split the widest gap between neighbouring positions (from three stops the next ones land at 28, 78, 14, 42, 67 percent), press Reverse stops to flip the ramp, or remove a stop with its × button.
  5. Copy CSS puts the output panel on the clipboard character for character; Reset returns the workbench to 135deg and the three default stops.

Defaults, the numbers that are snapped on commit, and what this page leaves out

Defaults and what the numbers do

Three stops, 135 degrees, linear: those are the values the page loads with and the values Reset restores. The output is a single declaration, .gradient-background { background: … ; }, ordered by stop position, so a stop added between 0 and 55 is printed before 55 even though it was added last.

The angle only exists for linear-gradient() and conic-gradient(). Conic prints it as from 90deg at center; radial prints circle at center and no angle. Positions are written with one decimal, the same precision the field shows after you commit.

Two to eight stops

A gradient needs at least two stops: at two, the × button reports that a gradient requires at least two colour stops instead of removing one. Eight is the ceiling — at eight stops the Add colour stop button is disabled, so the cap is visible rather than a click that does nothing.

Adding uses the widest gap between the stops you already have, which keeps the ramp even: four stops from the default become 0, 28, 55, 100 percent, and the full eight become 0, 14, 28, 42, 55, 67, 78, 100. Reverse stops mirrors every position (100 minus the position) and flips the list; the exported declaration is always sorted by position afterwards.

What this page does not do

Stop colours are six-digit HEX values or the colour picker. Three-digit shorthand such as #fff is not expanded — the page keeps the last valid gradient and asks for six digits — and hsl() or rgba() written into a HEX field is refused the same way.

There is no image, SVG or PNG export, no opacity or interpolation-hint slider, no second gradient layer, and no way to preview the ramp inside your own container size. The declaration, copied from the output panel, is the whole product.

Recent tools: