Skip to content
Inkoxide

Search covers every page and heading of the docs. Use ↑ ↓ and ↵.

SVG

Vector drawing in JSX: shapes, paths, gradients, markers and SVG text.

Edit this page

Import them from @inkoxide/render. Examples, and how these components work together, are in the guide.

Presentation attributes

SVG presentation attributes, camelCase (strokeWidth), as in React DOM. Every shape, G, Svg and SVG Text takes them, besides its own props below.

AttributeTypeDescription
fillSvgPaint
fillOpacitynumber | string
fillRule'nonzero' | 'evenodd'
strokeSvgPaint
strokeWidthnumber | string
strokeOpacitynumber | string
strokeLinecap'butt' | 'round' | 'square'
strokeLinejoin'miter' | 'round' | 'bevel'
strokeDasharraystring | number[]
strokeDashoffsetnumber | string
strokeMiterlimitnumber | string
opacitynumber | string
transformstring
clipPathstring
clipRule'nonzero' | 'evenodd'
markerStartstringA <Marker> drawn at the first vertex of a path, line or poly shape: url(#id).
markerMidstringA <Marker> drawn at every vertex between the first and the last: url(#id).
markerEndstringA <Marker> drawn at the last vertex: url(#id).
visibility'visible' | 'hidden' | 'collapse'
fontFamilystringText inside: the font, as in CSS. A family list ("Inter, sans-serif") is a stack.
fontSizenumber | string
fontWeightnumber | FontWeightName
fontStyle'normal' | 'italic'
textAnchor'start' | 'middle' | 'end'Text inside: where its position is on the text (start, middle, end).
dominantBaseline| 'auto' | 'alphabetic' | 'middle' | 'central' | 'hanging' | 'mathematical' | 'ideographic' | 'text-before-edge' | 'text-after-edge'Text inside: which line of the text sits at its y.
idstring

Svg

A vector drawing; becomes an SVG image. Use the SVG primitives (Path, Rect, …) inside.

import { Document, Page, Path, Rect, Svg, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={100} height={80} viewBox="0 0 100 80">
            <Rect x={8} y={40} width={22} height={36} rx={3} fill="#f3c5b0" />
            <Rect x={38} y={24} width={22} height={52} rx={3} fill="#e8956f" />
            <Rect x={68} y={12} width={22} height={64} rx={3} fill="#c4471b" />
            <Path d="M0 77 L120 77" stroke="#9ca3af" strokeWidth={1} />
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.
PropTypeDescription
width (required)LengthWidth and height of the drawing in the layout (points or units); also the SVG viewport.
height (required)Length
viewBoxstring
preserveAspectRatiostring
classNamestringBox utilities for the image the drawing becomes (margins, position, pages…).
styleStyle
pagesPageFilter
breakBreakProp
hrefstring
fixedbooleanRepeats the drawing on every page, like fixed on a View.
debugbooleanOutlines the drawing's box.

It also takes the presentation attributes.

G

A group: its presentation attributes and transform apply to every shape inside it.

import { Circle, Document, G, Page, Svg, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={120} height={80} viewBox="0 0 120 80">
            <G fill="#c4471b" transform="translate(20 40)">
              <Circle cx={0} cy={0} r={12} />
              <Circle cx={40} cy={0} r={12} opacity={0.6} />
              <Circle cx={80} cy={0} r={12} opacity={0.3} />
            </G>
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.

It takes the presentation attributes.

Path

A shape drawn by the commands of d (M, L, C, Q, A, Z and the others of SVG).

import { Document, Page, Path, Svg, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={120} height={80} viewBox="0 0 120 80">
            <Path d="M4 64 C 30 4, 60 4, 80 40 S 110 76, 116 16" fill="none" stroke="#c4471b" strokeWidth={3} strokeLinecap="round" />
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.
PropTypeDescription
d (required)string

It also takes the presentation attributes.

Rect

A rectangle, with rounded corners when rx or ry is set.

import { Document, Page, Rect, Svg, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={120} height={80} viewBox="0 0 120 80">
            <Rect x={4} y={10} width={112} height={60} rx={10} fill="#fbe3d6" stroke="#c4471b" strokeWidth={2} />
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.
PropTypeDescription
xnumber | string
ynumber | string
width (required)number | string
height (required)number | string
rxnumber | string
rynumber | string

It also takes the presentation attributes.

Circle

A circle of radius r around cx, cy.

import { Circle, Document, Page, Svg, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={120} height={80} viewBox="0 0 120 80">
            <Circle cx={60} cy={40} r={32} fill="#fbe3d6" stroke="#c4471b" strokeWidth={3} />
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.
PropTypeDescription
cxnumber | string
cynumber | string
r (required)number | string

It also takes the presentation attributes.

Ellipse

An ellipse of radii rx and ry around cx, cy.

import { Document, Ellipse, Page, Svg, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={120} height={80} viewBox="0 0 120 80">
            <Ellipse cx={60} cy={40} rx={54} ry={26} fill="#fbe3d6" stroke="#c4471b" strokeWidth={2} />
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.
PropTypeDescription
cxnumber | string
cynumber | string
rx (required)number | string
ry (required)number | string

It also takes the presentation attributes.

Line

A straight line from x1, y1 to x2, y2.

import { Document, Line, Page, Svg, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={120} height={80} viewBox="0 0 120 80">
            <Line x1={8} y1={70} x2={112} y2={10} stroke="#c4471b" strokeWidth={3} strokeDasharray="8 5" />
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.
PropTypeDescription
x1 (required)number | string
y1 (required)number | string
x2 (required)number | string
y2 (required)number | string

It also takes the presentation attributes.

Polyline

Straight lines through points, left open.

import { Document, Page, Polyline, Svg, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={120} height={80} viewBox="0 0 120 80">
            <Polyline points="4,70 28,44 52,54 76,22 100,32 116,8" fill="none" stroke="#c4471b" strokeWidth={3} strokeLinejoin="round" />
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.
PropTypeDescription
points (required)string | number[]

It also takes the presentation attributes.

Polygon

Straight lines through points, closed back to the first.

import { Document, Page, Polygon, Svg, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={120} height={80} viewBox="0 0 120 80">
            <Polygon points="60,4 74,30 104,32 80,50 88,78 60,62 32,78 40,50 16,32 46,30" fill="#e8956f" stroke="#c4471b" strokeWidth={2} />
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.
PropTypeDescription
points (required)string | number[]

It also takes the presentation attributes.

Text in an Svg

A Text inside an <Svg>: SVG text, positioned in the drawing's coordinates.

import { Document, Page, Rect, Svg, Text, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={160} height={60} viewBox="0 0 160 60">
            <Rect width={160} height={60} rx={6} fill="#fbe3d6" />
            <Text x={80} y={28} textAnchor="middle" fontWeight="bold" fill="#c4471b">
              Revenue
            </Text>
            <Text x={80} y={46} textAnchor="middle" fontSize={9} letterSpacing={1}>
              Q3 2026
            </Text>
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.
PropTypeDescription
xSvgNumberListWhere the text starts (with textAnchor); a list positions each character.
ySvgNumberList
dxSvgNumberListShifts from where each character would be.
dySvgNumberList
rotateSvgNumberListDegrees each character is turned; the last value repeats.
letterSpacingnumber | string
wordSpacingnumber | string
textDecorationstringunderline, overline, line-through, or several.
textLengthnumber | stringThe width to fit the text to, by its spacing or (lengthAdjust) its glyphs too.
lengthAdjust'spacing' | 'spacingAndGlyphs'
direction'ltr' | 'rtl'

It also takes the presentation attributes.

Tspan

A span of SVG text, inside a Text in an <Svg>: its own position, font or paint.

import { Document, Page, Rect, Svg, Text, Tspan, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={160} height={60} viewBox="0 0 160 60">
            <Rect width={160} height={60} rx={6} fill="#f5f5f4" />
            <Text x={80} y={36} textAnchor="middle" fontWeight="bold">
              Revenue <Tspan fill="#16a34a">+12%</Tspan>
            </Text>
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.
PropTypeDescription
baselineShiftnumber | stringRaises (positive, super) or lowers (sub) the span from the baseline.
alignmentBaselineSvgPresentation['dominantBaseline']
xSvgNumberListWhere the text starts (with textAnchor); a list positions each character.
ySvgNumberList
dxSvgNumberListShifts from where each character would be.
dySvgNumberList
rotateSvgNumberListDegrees each character is turned; the last value repeats.
letterSpacingnumber | string
wordSpacingnumber | string
textDecorationstringunderline, overline, line-through, or several.
textLengthnumber | stringThe width to fit the text to, by its spacing or (lengthAdjust) its glyphs too.
lengthAdjust'spacing' | 'spacingAndGlyphs'
direction'ltr' | 'rtl'

It also takes the presentation attributes.

Defs

What other elements refer to by id (gradients, clip paths, markers), not drawn where it stands.

import { Defs, Document, LinearGradient, Page, Rect, Stop, Svg, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={120} height={80} viewBox="0 0 120 80">
            <Defs>
              <LinearGradient id="fade" x1={0} y1={0} x2={1} y2={0}>
                <Stop offset={0} stopColor="#c4471b" />
                <Stop offset={1} stopColor="#f3c5b0" />
              </LinearGradient>
            </Defs>
            <Rect x={4} y={16} width={112} height={48} rx={8} fill="url(#fade)" />
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.

It takes no props.

ClipPath

A shape that clips what refers to it with clipPath="url(#id)".

import { Circle, ClipPath, Defs, Document, G, Page, Rect, Svg, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={120} height={80} viewBox="0 0 120 80">
            <Defs>
              <ClipPath id="disc">
                <Circle cx={60} cy={40} r={34} />
              </ClipPath>
            </Defs>
            <G clipPath="url(#disc)">
              <Rect x={0} y={0} width={120} height={40} fill="#e8956f" />
              <Rect x={0} y={40} width={120} height={40} fill="#5e3428" />
            </G>
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.
PropTypeDescription
id (required)stringReferenced as clipPath="url(#id)".
clipPathUnits'userSpaceOnUse' | 'objectBoundingBox'What the contents' coordinates are in: the user space (default) or the clipped shape's bounding box.

Marker

A shape drawn at the vertices of the paths, lines and poly shapes that reference it through markerStart, markerMid or markerEnd. Defined once, in Defs.

import { Defs, Document, Line, Marker, Page, Path, Svg, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={120} height={80} viewBox="0 0 120 80">
            <Defs>
              <Marker id="arrow" viewBox="0 0 10 10" refX={8} refY={5} markerWidth={6} markerHeight={6} orient="auto-start-reverse">
                <Path d="M0 0 L10 5 L0 10 z" fill="#c4471b" />
              </Marker>
            </Defs>
            <Line x1={12} y1={40} x2={108} y2={40} stroke="#c4471b" strokeWidth={2} markerStart="url(#arrow)" markerEnd="url(#arrow)" />
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.
PropTypeDescription
id (required)stringReferenced as markerStart="url(#id)" (or markerMid, markerEnd).
viewBoxstring
preserveAspectRatiostring
refXnumber | stringThe point of the marker's contents placed on the vertex, in viewBox units.
refYnumber | string
markerWidthnumber | stringThe size of the marker's viewport; 3 × 3 by default.
markerHeightnumber | string
orient'auto' | 'auto-start-reverse' | number | stringTurns the marker with the path's direction at the vertex ('auto'), the same but reversed at the start ('auto-start-reverse', for arrows at both ends), or by a fixed angle in degrees.
markerUnits'strokeWidth' | 'userSpaceOnUse'strokeWidth (default) scales the marker by the shape's stroke width; userSpaceOnUse does not.

It also takes the presentation attributes.

LinearGradient

A gradient along a line, used as a paint: fill="url(#id)".

import { Defs, Document, LinearGradient, Page, Rect, Stop, Svg, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={120} height={80} viewBox="0 0 120 80">
            <Defs>
              <LinearGradient id="sky" x1={0} y1={0} x2={0} y2={1}>
                <Stop offset={0} stopColor="#f6c79a" />
                <Stop offset={1} stopColor="#9c5a43" />
              </LinearGradient>
            </Defs>
            <Rect x={4} y={4} width={112} height={72} rx={8} fill="url(#sky)" />
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.
PropTypeDescription
id (required)string
x1number | string
y1number | string
x2number | string
y2number | string
cxnumber | string
cynumber | string
rnumber | string
fxnumber | string
fynumber | string
frnumber | stringRadius of the focal circle of a radial gradient.
gradientUnits'userSpaceOnUse' | 'objectBoundingBox'
gradientTransformstring

RadialGradient

A gradient out from a centre, used as a paint: fill="url(#id)".

import { Circle, Defs, Document, Page, RadialGradient, Stop, Svg, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={120} height={80} viewBox="0 0 120 80">
            <Defs>
              <RadialGradient id="sun" cx={0.4} cy={0.4} r={0.6}>
                <Stop offset={0} stopColor="#fff4e2" />
                <Stop offset={1} stopColor="#e8956f" />
              </RadialGradient>
            </Defs>
            <Circle cx={60} cy={40} r={34} fill="url(#sun)" />
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.
PropTypeDescription
id (required)string
x1number | string
y1number | string
x2number | string
y2number | string
cxnumber | string
cynumber | string
rnumber | string
fxnumber | string
fynumber | string
frnumber | stringRadius of the focal circle of a radial gradient.
gradientUnits'userSpaceOnUse' | 'objectBoundingBox'
gradientTransformstring

Stop

A colour of a gradient, at its offset (0 to 1).

import { Defs, Document, LinearGradient, Page, Rect, Stop, Svg, View } from '@inkoxide/render';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 140]}>
        <View className="flex-1 items-center justify-center">
          <Svg width={120} height={80} viewBox="0 0 120 80">
            <Defs>
              <LinearGradient id="bands" x1={0} y1={0} x2={1} y2={0}>
                <Stop offset={0} stopColor="#c4471b" />
                <Stop offset={0.5} stopColor="#f3c5b0" stopOpacity={0.6} />
                <Stop offset={1} stopColor="#5e3428" />
              </LinearGradient>
            </Defs>
            <Rect x={4} y={20} width={112} height={40} rx={6} fill="url(#bands)" />
          </Svg>
        </View>
      </Page>
    </Document>
  );
}
The PDF this example renders.
PropTypeDescription
offset (required)number | string
stopColor (required)string
stopOpacitynumber | string

Synced from components/svg.md in the inkoxide repository.