Skip to main content
Forme provides 19 components for building PDF documents. All components are imported from @formepdf/react.
Svelte users: every component below is also exported from @formepdf/svelte with identical props. Swap the import path and the JSX examples work as .svelte markup unchanged. See the Svelte guide for setup.

Styling

Styles are plain objects passed to the style 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

Every Forme document starts with <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

Content that exceeds the page height automatically flows to additional pages with the same size and margins.

View

A flex container, analogous to an HTML <div>. Defaults to column layout.

Props

Example

Views use flexbox column layout by default. All flex properties (flexDirection, justifyContent, alignItems, flexWrap, gap, flexGrow, flexShrink) are supported. Set position: 'absolute' in the style to position a View relative to its parent’s content box.

Text

Renders text content with font properties, colors, and alignment.

Props

Example

Text wraps automatically based on the available width. Use {{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

If only 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

Tables automatically break across pages between rows. Header rows (marked with 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

Cells can contain any Forme element, not just Text.

Svg

Renders inline SVG graphics. Supports basic SVG elements: rect, circle, ellipse, line, polyline, polygon, and path. Elements support opacity, fill-opacity, and stroke-opacity attributes with proper inheritance through <g> groups.

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

JSX children are serialized to SVG XML automatically. CamelCase props like 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

QR codes are rendered as filled rectangles in the PDF — one rectangle per dark module. This is a native vector representation, not an embedded image, which keeps file sizes small and output sharp.

Barcode

Renders a 1D barcode from a data string. Output is vector-based (filled rectangles), crisp at any zoom level.

Props

Example

Barcodes are rendered as filled rectangles in the PDF — one rectangle per dark bar. Supported formats: Code 128 (general purpose), Code 39 (alphanumeric), EAN-13 (retail products), EAN-8 (small packages), and Codabar (libraries, blood banks).

Fixed

An element that repeats on every page as a header or footer. Reduces the available content area on each page.

Props

Example

Use {{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

PageBreak is useful for separating document sections (e.g., cover page from content, or chapters from each other).

Canvas

Renders arbitrary vector graphics via a draw 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).

Example


BarChart

Engine-native bar chart rendered directly to PDF vector graphics.

Props

Example


LineChart

Engine-native multi-series line chart with optional data points and grid.

Props

Example


PieChart

Engine-native pie or donut chart with optional legend.

Props

Example


AreaChart

Engine-native multi-series area chart — like LineChart with semi-transparent fill under each line.

Props

Example


DotPlot

Engine-native scatter plot for (x, y) data with multiple groups.

Props

Example


Watermark

Renders rotated text behind all page content. Automatically repeated on every page.

Props

Example


Forms

Forme supports AcroForm components for creating fillable PDF forms. See the Forms page for full documentation.