Features

Gradients

Gradient fills, strokes, and borders, with element-specific properties and export limitations

Polotno accepts linear-gradient() and radial-gradient() strings in supported paint properties. Figures and text use fill and stroke; lines use color. Image and SVG borders use borderColor with a non-zero borderSize. Use colorsReplace to change paints inside an SVG.

Gradient fill

For a figure or text element, set fill to a gradient string:

element.set({
  fill: 'linear-gradient(90deg, #ff6b6b 0%, #4ecdc4 100%)',
});

Use degree angles or directional keywords, with percentage color stops. Multiple stops and rgba() colors with alpha are supported. Other CSS angle units (turn, rad) and stop positions in length units (px) are not interpreted as CSS defines them.

Gradient stroke

For figures and text, use stroke with a non-zero strokeWidth:

element.set({
  stroke: 'linear-gradient(45deg, #f7b733 0%, #fc4a1a 100%)',
  strokeWidth: 6,
});

Fill and stroke are independent, so an element can carry a solid fill with a gradient stroke, or two different gradients.

Lines use color for their paint and height for their thickness:

lineElement.set({
  color: 'linear-gradient(45deg, #f7b733 0%, #fc4a1a 100%)',
  height: 6,
});

On text

Text supports both, including on curved and stroked text. A gradient applied to a text element is measured against the text's own bounding box, so it stays correct when the element is rotated or the text is set on a curve.

textElement.set({
  fill: 'linear-gradient(180deg, #ffd700 0%, #ff8c00 100%)',
  stroke: 'linear-gradient(180deg, #8b4513 0%, #3e1f08 100%)',
  strokeWidth: 2,
});

Direction

Angular syntax (90deg) and CSS directional keywords (to right, to top left) are both parsed. The editor UI writes angular gradients; keywords are supported mainly so hand-written or imported JSON keeps working.

Radial gradients

A radial-gradient() spreads its stops out from a center:

element.set({
  fill: 'radial-gradient(circle at 30% 40%, #ffffff 0%, #1e3a8a 100%)',
});

The shape is a circle or an ellipse. Size it with an extent keyword (closest-side, closest-corner, farthest-side, or farthest-corner, the default) or with lengths, and place its center with at, in percentages or px. A circle stays round on a box of any shape. In the editor, the color picker's Gradient tab switches between Linear and Radial. A new radial is a circle at the middle, and users move its center on the picker's pad or by dragging its handle on the canvas.

Export support

Export behavior depends on the element and format. Image rendering preserves the canvas appearance; vector exporters retain the gradient paints they support. PPTX text fill and outlines use the first gradient stop as a solid color. A gradient on the canvas does not guarantee a gradient in every export. See PPTX export for format limitations.

For PDF/X-4 output with colorMode: 'cmyk', gradients are converted through the output profile along with every other fill and stroke. See PDF export.

On this page