GitHub

Presentation Attributes

SVG presentation attributes are CSS properties that can be used as attributes on SVG elements. This means it can be passed either inside a style object or directly by element's props.

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

const Attributes = () => (
  <Svg viewBox="0 0 120 60" width={240} height={120}>
    <Rect x="8" y="14" width="44" height="32" fill="#e82200" opacity={0.4} />
    <Circle
      cx="88"
      cy="30"
      r="20"
      fill="#c9c2b6"
      stroke="#8d1602"
      strokeWidth={3}
      strokeDasharray="6 4"
    />
  </Svg>
);
Show preview

Supported attributes

Prop nameDescriptionTypeDefault
colorProvides a potential indirect value for the fill or stroke attributes.Stringundefined
dominantBaselineDefines the baseline used to align the box’s text and inline-level contents.Stringauto
fillIt defines the color of the inside of the graphical element it applies to.Stringundefined
fillOpacityIt specifies the opacity of the color or the content the current object is filled with.String, Number1
fillRuleIt indicates how to determine what side of a path is inside a shape.Stringnonzero
opacityIt specifies the transparency of an object or a group of objects.String, Number1
strokeDefines the color used to paint the outline of the shape.Stringundefined
strokeWidthDefines the width of the stroke to be applied to the shape.String, Number1
strokeOpacityDefines the opacity of the stroke of a shape.String, Number1
strokeLinecapDefines the shape to be used at the end of open subpaths when they are stroked.Stringbutt
strokeLinejoinDefines the shape to be used at the corners of paths when they are stroked.Stringmiter
strokeDasharrayDefines the pattern of dashes and gaps used to paint the outline of the shape.Stringundefined
transformDefines a list of transform definitions that are applied to an element and the element's children.Stringundefined
textAnchorDefines the horizontal alignment of a string of text.Stringundefined
visibilityLets you control the visibility of graphical elements.Stringvisible
clipPathReferences a ClipPath restricting where paint is applied.Stringundefined
markerStartReferences a Marker drawn on the first vertex of the shape.Stringundefined
markerMidReferences a Marker drawn on every intermediate vertex of the shape.Stringundefined
markerEndReferences a Marker drawn on the last vertex of the shape.Stringundefined

On this page