GitHub

LinearGradient

The <LinearGradient /> element lets authors define linear gradients that can be applied to fill or stroke of graphical elements.

import { Svg, Defs, LinearGradient, Stop, Rect } from '@react-pdf/renderer';

const Ember = () => (
  <Svg viewBox="0 0 120 60" width={240} height={120}>
    <Defs>
      <LinearGradient id="ember" x1="0" y1="0" x2="1" y2="0">
        <Stop offset="0" stopColor="#e82200" />
        <Stop offset="1" stopColor="#8d1602" />
      </LinearGradient>
    </Defs>
    <Rect x="8" y="14" width="104" height="32" rx="4" fill="url(#ember)" />
  </Svg>
);
Show preview

Valid props

Prop nameDescriptionTypeDefault
x1Defines the x coordinate of the starting point of the vector gradient along which the linear gradient is drawn.String, Numberundefined
x2Defines the x coordinate of the ending point of the vector gradient along which the linear gradient is drawn.String, Numberundefined
y1Defines the y coordinate of the starting point of the vector gradient along which the linear gradient is drawn.String, Numberundefined
y2Defines the y coordinate of the ending point of the vector gradient along which the linear gradient is drawn.String, Numberundefined
xlinkHrefReference to another gradient to inherit its stops and attributes from.Stringundefined
gradientTransformDefines a transformation to be applied to the gradient.Stringundefined
gradientUnitsDefines the coordinate system for the gradient attributes. Valid values: "userSpaceOnUse" or "objectBoundingBox"Stringundefined

On this page