# docxio > JSX in, DOCX out. Generate Word documents with JSX syntax, powered by Rust and WASM. ## docs ### api - [Components](/docs/api/components.md): Complete reference for all 23 JSX components available in docxio - [Quick Reference](/docs/api/quick-reference.md): Single-page API cheat sheet for docxio - [Render Functions](/docs/api/render.md): API reference for render, renderToStream, and other output functions - [Template API](/docs/api/template.md): Load .docx templates and replace placeholders with dynamic content - [Themes API](/docs/api/themes.md): Apply consistent fonts, colors, heading styles, and page margins via themes ### architecture - [Architecture Overview](/docs/architecture/overview.md): Data flow from JSX to DOCX through the Rust WASM pipeline - [Rust Crates](/docs/architecture/rust-crates.md): Layered workspace of 10 Rust crates powering docxio - [Security](/docs/architecture/security.md): Security model including Rust guarantees, input validation, and CI auditing ### contributing How to set up the development environment and contribute to docxio - [Contributing](/docs/contributing.md): How to set up the development environment and contribute to docxio ### getting-started - [Configuration](/docs/getting-started/configuration.md): Configure backend options, bundler plugins, and TypeScript settings - [Installation](/docs/getting-started/installation.md): Install docxio and configure your project - [Quick Start](/docs/getting-started/quick-start.md): Create your first .docx document with docxio in minutes ### guides - [Data Components](/docs/guides/data-components.md): Higher-level components like DataTable, PageNumbers, Watermark, and more - [Headers and Footers](/docs/guides/headers-footers.md): Add headers and footers to document sections - [HTML and Markdown Export](/docs/guides/html-markdown-export.md): Convert docxio document trees to HTML or Markdown strings - [Images](/docs/guides/images.md): Embed inline and floating images in documents - [Lists](/docs/guides/lists.md): Create bullet and numbered lists with nesting support - [Paragraphs and Formatting](/docs/guides/paragraphs-and-formatting.md): Create paragraphs, apply text formatting, and control alignment - [Streaming](/docs/guides/streaming.md): Stream .docx bytes as a ReadableStream for HTTP responses - [Styles and Themes](/docs/guides/styles-and-themes.md): Define reusable paragraph and character styles with theme support - [Tables](/docs/guides/tables.md): Build tables with rows, cells, merging, and borders - [Templates](/docs/guides/templates.md): Load .docx templates and replace placeholder tokens with dynamic values ### packages - [@docxio/bun](/docs/packages/bun.md): Bun build plugin for WASM resolution and JSX configuration - [@docxio/html](/docs/packages/html.md): HTML and Markdown export for docxio document trees - [@docxio/node](/docs/packages/node.md): Native Node.js bindings via napi-rs for server-side document generation - [@docxio/wasm-minimal](/docs/packages/wasm-minimal.md): Minimal WASM binary for browser-side OOXML generation without ZIP - [@docxio/zip](/docs/packages/zip.md): JavaScript-side ZIP assembly for the minimal WASM backend ### reference - [Glossary](/docs/reference/glossary.md): Terminology used in docxio documentation --- # Full Documentation Content # Components Complete reference for all 23 JSX components available in docxio. ## Document structure[​](#document-structure "Direct link to Document structure") ### ``[​](#document "Direct link to document") Root element. Maps to `w:document`. | Prop | Type | Description | | ------------------ | ---------------- | ------------------------------------------------ | | `creator` | `string` | Author metadata | | `title` | `string` | Document title metadata | | `description` | `string` | Subject/description metadata | | `keywords` | `string` | Keywords metadata | | `styles` | `DocumentStyles` | Custom paragraph and character style definitions | | `useDefaultStyles` | `boolean` | Include default Word styles (default: `true`) | | `theme` | `Theme` | Theme preset for document-wide styling | ### `
`[​](#section "Direct link to section") Page layout unit. Maps to `w:sectPr`. | Prop | Type | Description | | --------------- | ------------------------------------- | --------------------------------------------------------------- | | `pageSize` | `{ width?: number; height?: number }` | Page dimensions in twips | | `margins` | `PageMargins` | Page margins (top, right, bottom, left, header, footer, gutter) | | `orientation` | `"portrait" \| "landscape"` | Page orientation | | `columns` | `number \| ColumnDef[]` | Number of columns or column definitions | | `columnSpace` | `number` | Space between columns in twips | | `lineNumbers` | `object` | Line numbering config | | `isLastSection` | `boolean` | Suppress trailing page break | ## Text content[​](#text-content "Direct link to Text content") ### ``[​](#paragraph "Direct link to paragraph") Maps to `w:p`. | Prop | Type | Description | | ----------------- | ---------------- | -------------------------------------------------------------------------- | | `alignment` | `Alignment` | `"left"`, `"center"`, `"right"`, `"justify"`, `"start"`, `"end"`, `"both"` | | `spacing` | `Spacing` | `{ before?, after?, line?, lineRule? }` | | `indentation` | `Indentation` | `{ left?, right?, firstLine?, hanging? }` | | `style` | `string` | Named paragraph style | | `numbering` | `NumberingProps` | List numbering reference | | `border` | `Borders` | Paragraph borders | | `shading` | `Shading` | Background fill | | `keepNext` | `boolean` | Keep with next paragraph | | `keepLines` | `boolean` | Keep lines together | | `pageBreakBefore` | `boolean` | Page break before | | `widowControl` | `boolean` | Widow/orphan control | | `outlineLevel` | `number` | Outline level for TOC | | `bidi` | `boolean` | Right-to-left direction | ### ``[​](#run "Direct link to run") Text run. Maps to `w:r`. | Prop | Type | Description | | ------------------ | --------------------------- | ------------------------------- | | `bold` | `boolean` | Bold | | `italic` | `boolean` | Italic | | `underline` | `UnderlineStyle \| boolean` | Underline style | | `strike` | `boolean` | Strikethrough | | `doubleStrike` | `boolean` | Double strikethrough | | `fontSize` | `number` | Size in half-points (24 = 12pt) | | `fontFamily` | `string` | Font name | | `color` | `string` | Hex color (e.g., `"FF0000"`) | | `highlight` | `HighlightColor` | Background highlight | | `superscript` | `boolean` | Superscript | | `subscript` | `boolean` | Subscript | | `allCaps` | `boolean` | All capitals | | `smallCaps` | `boolean` | Small capitals | | `characterSpacing` | `number` | Spacing in twips | | `emboss` | `boolean` | Emboss effect | | `imprint` | `boolean` | Imprint effect | | `shadow` | `boolean` | Shadow | | `style` | `string` | Named character style | | `bidi` | `boolean` | Right-to-left | | `lang` | `string` | Language tag | ### ``[​](#heading "Direct link to heading") Heading paragraph. Maps to `w:p` + `w:pStyle`. | Prop | Type | Description | | ----------- | ---------------- | ------------------- | | `level` | `1-6` | Heading level | | `alignment` | `Alignment` | Text alignment | | `spacing` | `Spacing` | Paragraph spacing | | `numbering` | `NumberingProps` | Numbering reference | ## Tables[​](#tables "Direct link to Tables") ### ``[​](#table "Direct link to table") Maps to `w:tbl`. See [Tables guide](/docs/guides/tables.md). ### ``[​](#row "Direct link to row") Maps to `w:tr`. Props: `header`, `height`, `heightRule`, `cantSplit`. ### ``[​](#cell "Direct link to cell") Maps to `w:tc`. Props: `width`, `widthType`, `columnSpan`, `verticalMerge`, `verticalAlignment`, `shading`, `borders`, `margins`. ## Media[​](#media "Direct link to Media") ### ``[​](#image "Direct link to image") Maps to `w:drawing`. See [Images guide](/docs/guides/images.md). Props: `src` (required), `width`, `height`, `widthPt`, `heightPt`, `altText`, `floating`, `wrapText`, `floatPosition`, `format`. ## Links and bookmarks[​](#links-and-bookmarks "Direct link to Links and bookmarks") ### ``[​](#hyperlink "Direct link to hyperlink") Maps to `w:hyperlink`. | Prop | Type | Description | | --------- | -------- | ---------------------- | | `url` | `string` | External URL | | `anchor` | `string` | Internal bookmark name | | `tooltip` | `string` | Hover tooltip | ### ``[​](#bookmark "Direct link to bookmark") Maps to `w:bookmarkStart/End`. | Prop | Type | Description | | ------ | -------- | --------------------------- | | `name` | `string` | **Required.** Bookmark name | | `id` | `string` | Unique identifier | ## Headers and footers[​](#headers-and-footers "Direct link to Headers and footers") ### `
` / `
`[​](#header--footer "Direct link to header--footer") | Prop | Type | Description | | ------ | -------------------------------- | ------------------------------------ | | `type` | `"default" \| "first" \| "even"` | When this header/footer is displayed | ## Lists[​](#lists "Direct link to Lists") ### ``[​](#numbered-list "Direct link to numbered-list") Props: `format` (NumberingFormat), `start` (number), `reference` (string). ### ``[​](#bullet-list "Direct link to bullet-list") Props: `reference` (string). ### ``[​](#list-item "Direct link to list-item") Props: `level` (0-8), `numbering` (NumberingProps). ## Annotations[​](#annotations "Direct link to Annotations") ### ``[​](#comment "Direct link to comment") | Prop | Type | Description | | -------- | -------- | -------------- | | `author` | `string` | Comment author | | `date` | `string` | Comment date | | `id` | `string` | Comment ID | ### ``[​](#footnote "Direct link to footnote") Props: `id` (string). Content provided as children. ## Fields[​](#fields "Direct link to Fields") ### ``[​](#field "Direct link to field") Maps to `w:fldChar`. | Prop | Type | Description | | -------- | -------- | -------------------------------------------- | | `code` | `string` | Field code: `"PAGE"`, `"NUMPAGES"`, `"DATE"` | | `format` | `string` | Display format | ## Breaks and whitespace[​](#breaks-and-whitespace "Direct link to Breaks and whitespace") | Component | OOXML | Props | | --------------- | ------------------ | ---------------------------- | | `` | `w:br type=page` | -- | | `` | `w:br` | -- | | `` | `w:br type=column` | -- | | `` | `w:tab` | -- | | `` | `w:tabs` | `position`, `type`, `leader` | --- # Quick Reference Single-page cheat sheet for the docxio API. ## Components (23)[​](#components-23 "Direct link to Components (23)") ### Document Structure[​](#document-structure "Direct link to Document Structure") | Component | Key Props | | ------------ | ---------------------------------------------------------------------------------------------- | | `` | `creator`, `title`, `description`, `keywords`, `styles`, `useDefaultStyles`, `theme` | | `
` | `pageSize`, `margins`, `orientation`, `columns`, `columnSpace`, `lineNumbers`, `isLastSection` | ### Text[​](#text "Direct link to Text") | Component | Key Props | | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `` | `alignment`, `spacing`, `indentation`, `style`, `numbering`, `border`, `shading`, `keepNext`, `keepLines`, `pageBreakBefore`, `widowControl`, `outlineLevel`, `bidi` | | `` | `bold`, `italic`, `underline`, `strike`, `fontSize`, `fontFamily`, `color`, `highlight`, `superscript`, `subscript`, `allCaps`, `smallCaps`, `style`, `lang` | | `` | `level` (1-6), `alignment`, `spacing`, `numbering` | ### Tables[​](#tables "Direct link to Tables") | Component | Key Props | | --------- | -------------------------------------------------------------------------------------------------------------------- | | `
` | `width`, `widthType`, `borders`, `alignment`, `layout`, `style`, `indent`, `cellMargins`, `float` | | `` | `header`, `height`, `heightRule`, `cantSplit` | | `` | `width`, `widthType`, `borders`, `shading`, `verticalMerge`, `verticalAlignment`, `columnSpan`, `rowSpan`, `margins` | ### Media[​](#media "Direct link to Media") | Component | Key Props | | --------- | ------------------------------------------------------------------------------------------------------------------------ | | `` | `src` (required), `width`, `height`, `widthPt`, `heightPt`, `altText`, `floating`, `wrapText`, `floatPosition`, `format` | ### Links and Bookmarks[​](#links-and-bookmarks "Direct link to Links and Bookmarks") | Component | Key Props | | ------------- | -------------------------- | | `` | `url`, `anchor`, `tooltip` | | `` | `name` (required), `id` | ### Headers and Footers[​](#headers-and-footers "Direct link to Headers and Footers") | Component | Key Props | | ---------- | -------------------------------------------- | | `
` | `type`: `"default"` \| `"first"` \| `"even"` | | `
` | `type`: `"default"` \| `"first"` \| `"even"` | ### Lists[​](#lists "Direct link to Lists") | Component | Key Props | | ----------------- | ------------------------------ | | `` | `format`, `start`, `reference` | | `` | `reference` | | `` | `level` (0-8), `numbering` | ### Annotations[​](#annotations "Direct link to Annotations") | Component | Key Props | | ------------ | ---------------------- | | `` | `author`, `date`, `id` | | `` | `id` | ### Breaks and Whitespace[​](#breaks-and-whitespace "Direct link to Breaks and Whitespace") | Component | Key Props | | --------------- | ---------------------------- | | `` | -- | | `` | -- | | `` | -- | | `` | -- | | `` | `position`, `type`, `leader` | ### Fields[​](#fields "Direct link to Fields") | Component | Key Props | | --------- | ------------------------------------------------------------------- | | `` | `code` (required: `"PAGE"`, `"NUMPAGES"`, `"DATE"`, etc.), `format` | ## Render Functions[​](#render-functions "Direct link to Render Functions") ``` // Core render - returns raw .docx bytes render(tree: DocumentNode, options?: RenderOptions): Promise // Write directly to file (Node.js/Bun/Deno) renderToFile(tree: DocumentNode, path: string): Promise // Node.js Buffer renderToBuffer(tree: DocumentNode): Promise // Browser Blob (with correct MIME type) renderToBlob(tree: DocumentNode): Promise // Streaming (64KB chunks) renderToReadableStream(tree: DocumentNode, options?: RenderOptions): ReadableStream // Base64 string renderToBase64(tree: DocumentNode, options?: RenderOptions): Promise // Patch {{placeholder}} tokens in an existing .docx patchDocument(templateBytes: Uint8Array, replacements: Record): Promise ``` ### RenderOptions[​](#renderoptions "Direct link to RenderOptions") ``` interface RenderOptions { strict?: boolean; // Throw on validation errors (default: false) backend?: "minimal" | "full" | "auto"; // WASM backend (default: "auto") } ``` ## Template Functions[​](#template-functions "Direct link to Template Functions") ``` // Load and parse a .docx template, detecting {{slot}} placeholders loadTemplate(bytes: Uint8Array): Promise // Fill template slots with string values or DocumentNode content fillTemplate( template: ParsedTemplate, values: Record, options?: { openDelim?: string; closeDelim?: string } ): Promise ``` ### Template JSX Components[​](#template-jsx-components "Direct link to Template JSX Components") ``` // Declarative template filling ``` ## TypeScript Config[​](#typescript-config "Direct link to TypeScript Config") ``` { "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "docxio" } } ``` ## Common Patterns[​](#common-patterns "Direct link to Common Patterns") ### Minimal Document[​](#minimal-document "Direct link to Minimal Document") ``` import { render } from "docxio"; const doc = (
Hello, World!
); const bytes = await render(doc); ``` ### Table[​](#table "Direct link to Table") ```
Name Value Item 100
``` ### Styled Document[​](#styled-document "Direct link to Styled Document") ```
Title Styled paragraph
``` ### Template Filling[​](#template-filling "Direct link to Template Filling") ``` import { loadTemplate, fillTemplate } from "docxio"; import { readFile } from "node:fs/promises"; const bytes = await readFile("template.docx"); const tpl = await loadTemplate(new Uint8Array(bytes)); // String replacement const result = await fillTemplate(tpl, { title: "Quarterly Report", date: "2026-03-30", }); // Or JSX-based with