@formepdf/react.
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
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | - | PDF metadata title |
author | string | - | PDF metadata author |
subject | string | - | PDF metadata subject |
creator | string | - | PDF metadata creator application |
style | Style | - | Default style for the entire document. Sets global fontFamily, fontSize, color, etc. Inherited by all children. |
fonts | FontRegistration[] | - | Custom fonts to register for this document. See Fonts. |
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
| Prop | Type | Default | Description |
|---|---|---|---|
size | "A4" | "Letter" | "Legal" | "A3" | "A5" | "Tabloid" | { width, height } | "Letter" | Page dimensions. Custom sizes are in points (72 points = 1 inch). |
margin | number | { top, right, bottom, left } | 54 | Page margins in points. A single number applies to all sides. |
Example
View
A flex container, analogous to an HTML<div>. Defaults to column layout.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
style | Style | - | CSS-like style properties |
wrap | boolean | true | Whether this container can break across pages. Set to false to keep all children on the same page. |
href | string | - | URL to link to. Makes the entire View a clickable link in the PDF. |
bookmark | string | - | Adds a PDF outline (bookmark) entry with this label. Readers can jump to this View from the bookmark panel. |
Example
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
| Prop | Type | Default | Description |
|---|---|---|---|
style | Style | - | Typography and color styles |
children | string | number | Text | - | Text content. Nest <Text> inside <Text> for inline styling (bold a word, change colors mid-sentence). |
href | string | - | URL to link to. Makes this text a clickable link in the PDF. |
bookmark | string | - | Adds a PDF outline (bookmark) entry with this label. |
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
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | (required) | Image source: base64 data URI (data:image/png;base64,...) or file path |
width | number | - | Display width in points |
height | number | - | Display height in points |
style | Style | - | Additional style properties (margin, etc.) |
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
| Prop | Type | Default | Description |
|---|---|---|---|
columns | ColumnDef[] | - | Column width definitions |
style | Style | - | Style properties for the table container |
Column width types
| Type | Example | Description |
|---|---|---|
{ fraction: number } | { fraction: 0.5 } | Proportional width (0.5 = 50% of table width) |
{ fixed: number } | { fixed: 100 } | Fixed width in points |
"auto" | "auto" | Size to content |
Example
header) are repeated at the top of each continuation page.
Row
A table row. Must be a direct child of<Table>.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
header | boolean | false | Whether this is a header row. Header rows repeat on every page when a table spans multiple pages. |
style | Style | - | Style properties (e.g., backgroundColor for alternating rows) |
Example
Cell
A table cell inside a<Row>.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
colSpan | number | 1 | Number of columns this cell spans |
rowSpan | number | 1 | Number of rows this cell spans |
style | Style | - | Style properties (padding, background, etc.) |
Example
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
| Prop | Type | Default | Description |
|---|---|---|---|
width | number | (required) | Display width in points |
height | number | (required) | Display height in points |
viewBox | string | - | SVG viewBox attribute (e.g., "0 0 100 100") |
content | string | - | SVG markup string containing the elements to render |
children | ReactNode | - | JSX children as an alternative to content |
style | Style | - | Additional style properties (margin, etc.) |
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
| Prop | Type | Default | Description |
|---|---|---|---|
data | string | (required) | The data to encode (URL, text, etc.) |
size | number | - | Display size in points. QR codes are always square. Defaults to the available width. |
color | string | "#000000" | Color of the dark modules |
style | Style | - | Additional style properties (margin, etc.) |
Example
Barcode
Renders a 1D barcode from a data string. Output is vector-based (filled rectangles), crisp at any zoom level.Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | string | (required) | The data to encode |
format | "Code128" | "Code39" | "EAN13" | "EAN8" | "Codabar" | "Code128" | Barcode format |
width | number | - | Display width in points. Defaults to available width. |
height | number | 60 | Bar height in points |
color | string | "#000000" | Color of the bars |
style | Style | - | Additional style properties (margin, etc.) |
Example
Fixed
An element that repeats on every page as a header or footer. Reduces the available content area on each page.Props
| Prop | Type | Default | Description |
|---|---|---|---|
position | "header" | "footer" | (required) | Whether to place at the top or bottom of each page |
style | Style | - | Style properties |
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
| Prop | Type | Description |
|---|---|---|
width | number | Canvas width in points. |
height | number | Canvas height in points. |
draw | (ctx: CanvasContext) => void | Drawing callback. |
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
| Prop | Type | Default | Description |
|---|---|---|---|
width | number | — | Chart width in points. |
height | number | — | Chart height in points. |
data | ChartDataPoint[] | — | Data points ({ label, value, color? }). |
color | string | '#1a365d' | Default bar color (hex). Per-item color overrides this. |
showLabels | boolean | true | Show category labels on the X axis. |
showGrid | boolean | false | Show horizontal grid lines. |
showValues | boolean | false | Show value labels above bars. |
title | string | — | Chart title displayed above the chart. |
Example
LineChart
Engine-native multi-series line chart with optional data points and grid.Props
| Prop | Type | Default | Description |
|---|---|---|---|
width | number | — | Chart width in points. |
height | number | — | Chart height in points. |
series | ChartSeries[] | — | Data series ({ name, data: number[], color? }). |
labels | string[] | — | X-axis labels (one per data point). |
showPoints | boolean | false | Show dots at data points. |
showGrid | boolean | false | Show horizontal grid lines. |
title | string | — | Chart title. |
Example
PieChart
Engine-native pie or donut chart with optional legend.Props
| Prop | Type | Default | Description |
|---|---|---|---|
width | number | — | Chart width in points. |
height | number | — | Chart height in points. |
data | ChartDataPoint[] | — | Slices ({ label, value, color? }). Each slice should have a color. |
donut | boolean | false | Cut out the center to create a donut chart. |
showLegend | boolean | false | Show a legend beside the chart. |
title | string | — | Chart title. |
Example
AreaChart
Engine-native multi-series area chart — like LineChart with semi-transparent fill under each line.Props
| Prop | Type | Default | Description |
|---|---|---|---|
width | number | — | Chart width in points. |
height | number | — | Chart height in points. |
series | ChartSeries[] | — | Data series ({ name, data: number[], color? }). |
labels | string[] | — | X-axis labels. |
showGrid | boolean | false | Show horizontal grid lines. |
title | string | — | Chart title. |
Example
DotPlot
Engine-native scatter plot for (x, y) data with multiple groups.Props
| Prop | Type | Default | Description |
|---|---|---|---|
width | number | — | Chart width in points. |
height | number | — | Chart height in points. |
groups | DotPlotGroup[] | — | Groups ({ name, color?, data: [x, y][] }). |
xMin / xMax | number | auto | X-axis range. |
yMin / yMax | number | auto | Y-axis range. |
xLabel | string | — | X-axis label. |
yLabel | string | — | Y-axis label. |
showLegend | boolean | false | Show legend. |
dotSize | number | 4 | Dot radius in points. |
Example
Watermark
Renders rotated text behind all page content. Automatically repeated on every page.Props
| Prop | Type | Default | Description |
|---|---|---|---|
text | string | — | Watermark text. |
fontSize | number | 60 | Font size in points. |
color | string | 'rgba(0,0,0,0.1)' | Text color (supports rgba()). |
angle | number | -45 | Rotation angle in degrees. |
Example
Forms
Forme supports AcroForm components for creating fillable PDF forms. See the Forms page for full documentation.| Component | Description |
|---|---|
<TextField> | Text input field. Supports multiline, password, read-only. |
<Checkbox> | Checkbox with checked/unchecked state. |
<Dropdown> | Select dropdown with predefined options. |
<RadioButton> | Radio button, grouped by shared name. |