@ui-registries/pdf

API Reference

Complete reference of all exports from @ui-registries/pdf.

Components

Layout Components

All layout components accept className and style props. Styles from className are applied first, then style overrides.

ComponentWrapsDescription
BlockViewGeneral-purpose container (flexbox layout)
TextTextText content
PagePagePDF page
ImageImageJPG/PNG image
LinkLinkHyperlink
DocumentDocumentPDF document root (pass-through, no styling)
CanvasCanvasCustom drawing via paint callback
NoteNotePDF annotation (sticky note)
PageNumberTextPage number display via render prop

View is exported as a deprecated alias for Block.

SVG Components

ComponentclassNameDescription
Svg✓SVG container
G✓SVG group
SvgText✓SVG text element
Path—Path element
Rect—Rectangle
Circle—Circle
Ellipse—Ellipse
Line—Line
Polyline—Polyline
Polygon—Polygon
Tspan—Text span
Defs—Definitions container
ClipPath—Clip path
Stop—Gradient stop
LinearGradient—Linear gradient
RadialGradient—Radial gradient

Styling

Tailwind

Provider component that supplies a themed tw engine to all child components.

tsx
<Tailwind theme={{ "--color-brand": "#0073e6" }}>  <Document>...</Document></Tailwind>
PropTypeDescription
themeThemeVarsOptional theme variable overrides
childrenReactNodeChild components

useTw()

Hook that returns the TwFn from the nearest <Tailwind> provider, or the default tw if none is present.

ts
const tw = useTw();const styles = tw("p-4 bg-white");

Returns: TwFn

createTw(vars?)

Creates a standalone tw function with an optional custom theme.

ts
const tw = createTw({ "--color-brand": "#0073e6" });const styles = tw("p-4 bg-brand");
ParamTypeDescription
varsThemeVarsOptional theme variable overrides

Returns: TwFn

tw

Pre-created TwFn instance with the default theme. Equivalent to createTw().

ts
import { tw } from "@ui-registries/pdf";const styles = tw("flex flex-row gap-2 p-4");

resolveTheme(vars?)

Resolves theme variables into a structured theme object. Useful for inspecting computed values.

ts
const theme = resolveTheme({ "--color-brand": "#0073e6" });// theme.colors.brand → "#0073e6"// theme.spacing["4"] → 12// theme.fontSize.base → 12
ParamTypeDescription
varsThemeVarsOptional theme variable overrides

Returns: ResolvedTheme

cn(...args)

Lightweight class name joiner. Filters falsy values and joins with spaces.

ts
cn("p-4", isActive && "bg-blue-500", undefined, "text-white");// → "p-4 bg-blue-500 text-white"
ParamTypeDescription
...args(string | false | null | undefined)[]Class names to join

Returns: string


Fonts

defineFont(options)

Registers a font family and returns a FontResult with family, className, and style.

ts
const inter = defineFont({  family: "Inter",  src: [    { src: "/fonts/Inter-Regular.ttf", weight: 400 },    { src: "/fonts/Inter-Bold.ttf", weight: 700 },  ],});// inter.family → "Inter"// inter.className → "font-[Inter]"// inter.style → { fontFamily: "Inter" }
ParamTypeDescription
options.familystringFont family name
options.srcstring | FontVariant[]Single source URL/path, or array of variants

Returns: FontResult

See the Fonts guide for full usage details.


Re-exports

These are passed through directly from @react-pdf/renderer:

ExportTypeDescription
FontobjectFont registration and management
StyleSheetobjectStyleSheet.create() for typed style objects
PDFViewercomponentIframe PDF viewer (web only)
PDFDownloadLinkcomponentDownload link (web only)
BlobProvidercomponentBlob access (web only)
usePDFhookPDF instance hook (web only)
pdffunctionProgrammatic PDF generation

Types

Component Props

TypeFor
BlockPropsBlock
TextPropsText
PagePropsPage
ImagePropsImage
LinkPropsLink
CanvasPropsCanvas
NotePropsNote
PageNumberPropsPageNumber
SvgPropsSvg
GPropsG
SvgTextPropsSvgText

Engine Types

ts
type StyleValue = string | number;type StyleObject = Record<string, StyleValue>;type TwFn = (classString: string) => StyleObject;type ThemeVars = Record<string, string | number | "initial">;
interface ResolvedTheme {  spacingBase: number;  spacing: Record<string, number>;  fontSize: Record<string, number>;  borderRadius: Record<string, number>;  fontWeight: Record<string, number>;  fontFamily: Record<string, string>;  opacity: Record<string, number>;  lineHeight: Record<string, number>;  letterSpacing: Record<string, number>;  colors: Record<string, string>;}

Subpath Exports

@ui-registries/pdf/tw

Standalone tw engine without any React dependency. Use this in Node scripts, workers, or non-React contexts.

ts
import { createTw, tw, resolveTheme } from "@ui-registries/pdf/tw";

Exports: createTw, tw, resolveTheme, and all engine types.

@ui-registries/pdf/font

Standalone font registration without React. Use in build scripts or non-React contexts.

ts
import { defineFont } from "@ui-registries/pdf/font";

Exports: defineFont, and font types (DefineFontOptions, FontVariant, FontResult).