GitHub
SVGSvg

Svg

The <Svg /> element is a container that defines a new coordinate system and viewport. It is used as the outermost element of SVG documents.

import { Svg, Rect, Circle } from '@react-pdf/renderer';

const Canvas = () => (
  <Svg viewBox="0 0 120 60" width={240} height={120}>
    <Rect x="0" y="0" width="120" height="60" fill="#c9c2b6" />
    <Circle cx="60" cy="30" r="22" fill="#e82200" />
  </Svg>
);
Show preview

Valid props

Prop nameDescriptionTypeDefault
widthThe displayed width of the rectangular viewportString, Numberundefined
heightThe displayed height of the rectangular viewportString, Numberundefined
viewBoxThe SVG viewport coordinates for the current SVG fragmentStringundefined
preserveAspectRatioHow the svg fragment must be deformed if it is displayed with a different aspect ratio. See moreStringundefined
styleDefines SVG styles. See moreObject, Arrayundefined

On this page