@formepdf/react.
Svelte, Vue, or Preact users: every component below is also exported from@formepdf/svelte,@formepdf/vue, and@formepdf/preactwith identical props. Swap the import path and the examples carry over unchanged (.sveltemarkup for Svelte;.vuesingle-file components for Vue; Preact JSX for Preact).
Styling
Styles are plain objects passed to thestyle prop. You can write them inline or extract them with StyleSheet.create() for TypeScript autocomplete:
StyleSheet.create() is an identity function. It returns the same object you pass in. Its purpose is to provide autocomplete and type checking on style properties.
Document
Root container for every Forme document. All other components must be descendants of<Document>.
Props
Example
<Document>. If no <Page> children are provided, content uses the default page configuration (Letter size, 54pt margins).
Page
Defines a page boundary with explicit size and margin configuration. Content inside each<Page> is laid out independently.
Props
Example
View
A flex container, analogous to an HTML<div>. Defaults to column layout.
Props
Example
flexDirection, justifyContent, alignItems, flexWrap, gap, flexGrow, flexShrink) are supported. Set position: 'absolute' to position a View relative to its nearest positioned ancestor — an element with position: 'relative' or 'absolute' — or the page content box if there is none. Give the intended container position: 'relative' (as the card above does), or the absolute box will resolve against the page.
Text
Renders text content with font properties, colors, and alignment.Props
Example
{{pageNumber}} and {{totalPages}} placeholders for dynamic page numbering. Nested <Text> elements share the same line and can have different styles, which is useful for inline formatting like bold words, colored spans, or strikethrough pricing.
Image
Embeds a JPEG or PNG image. Aspect ratio is preserved when only one dimension is specified.Props
Example
width is provided, height is calculated from the image’s aspect ratio (and vice versa). Both JPEG and PNG formats are supported, including PNG transparency.
Table
Table container with column definitions. Children should be<Row> elements.
Props
Column width types
Example
header) are repeated at the top of each continuation page.
Row
A table row. Must be a direct child of<Table>.
Props
Example
Cell
A table cell inside a<Row>.
Props
Example
Svg
Renders inline SVG graphics as native PDF vector drawing. The markup is parsed by usvg, so it supports what SVG files exported by design tools and chart libraries use: shapes and paths,<g> with transform, <use>, <clipPath>, linear and radial gradients (stops that fade through stop-opacity included), dashes, fill rules, opacity, fill-opacity and stroke-opacity, and CSS through <style>, class and style="".
content can be the inner markup or a whole <svg> document, such as a pasted icon. A whole document supplies its own viewBox when the viewBox prop is not set.
<text> is drawn as real text with Forme’s text engine, so registered fonts, fallback chains and right-to-left scripts work, and the text can be selected and searched. It is positioned by x, y, dx, dy, transform, text-anchor and dominant-baseline, and a <tspan> can start a new line with its own x/y/dy (as chart libraries write multi-line labels) or restyle a word with its own fill, font, weight or size. Text is styled from attributes and CSS, and inherits the font of the element around the <Svg> when it sets none. Text draws over the SVG’s shapes and is not clipped by a <clipPath>.
Not drawn, and named in the render warnings when present: <image>, <foreignObject>, masks, filters, pattern fills, <textPath>, stroked text, letter spacing on text, baseline-shift, and per-character position lists (x="1 2 3"; the first value is used). A translucent <g> applies its opacity to each shape inside it, so shapes that overlap inside the group show through each other.
Props
Provide either
content (a raw SVG string) or JSX children — not both. If both are provided, content takes priority.
Example — content string
Example — JSX children
strokeWidth are converted to their kebab-case SVG equivalents (stroke-width).
SVG content is rendered directly into the PDF using native PDF drawing operations, not rasterized. This produces crisp vector output at any zoom level.
QrCode
Renders a QR code from a data string. Output is vector-based (not a raster image), so it stays crisp at any zoom level.Props
Example
Barcode
Renders a 1D barcode from a data string. Output is vector-based (filled rectangles), crisp at any zoom level.Props
Example
Fixed
An element that repeats on every page as a header or footer. Reduces the available content area on each page.Props
Example
{{pageNumber}} and {{totalPages}} placeholders inside Fixed elements for automatic page numbering.
PageBreak
Forces content after this element to start on a new page.Props
None.Example
Canvas
Renders arbitrary vector graphics via adraw callback. The callback receives a recording context with a Canvas-like API. All drawing commands are serialized and rendered as native PDF vector operations.
Props
CanvasContext methods
moveTo(x, y), lineTo(x, y), line(x1, y1, x2, y2), bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y), quadraticCurveTo(cpx, cpy, x, y), arc(cx, cy, r, startAngle, endAngle, counterclockwise?), circle(cx, cy, r), rect(x, y, w, h), ellipse(cx, cy, rx, ry), closePath(), stroke(), fill(), setFillColor(r, g, b), setStrokeColor(r, g, b), setLineWidth(w), setLineCap(cap), setLineJoin(join), save(), restore().
line(x1, y1, x2, y2) is a convenience that emits moveTo + lineTo + stroke in one call.
Colors use 0-255 RGB values (like HTML Canvas). Content is clipped to the canvas bounds (matching HTML Canvas behavior).