Template Components
A comprehensive guide to all available components in document templates (PDF and Excel).
Table of Contents
- Overview
- Component Categories
- Template Type Support
- Layout Components
- Content Components
- Data Components
- Interactive Components
- Advanced Components
- Best Practices
- Complete Examples
Overview
Templates are built using a component-based architecture. Each component represents a visual or functional element in your document. Components can be simple (like text or images) or complex (like tables with calculations or conditional sections).
Key Concepts
Component Structure: Every component has:
id(string, required): Unique identifiertype(string, required): Component type (e.g., "text", "button", "table")props(object, optional): Component properties and configurationchildren(array, optional): Nested child componentscontent(string, optional): Text content for some components
Template Types: Components can be used in:
- PDF templates: Rendered as PDF documents
- Excel templates: Rendered as Excel spreadsheets
- Both: Works in both template types
Variable Support: Most components support Handlebars syntax {{variableName}} for dynamic content.
Component Categories
Layout Components
Structure and organize other components:
- Container - Wrapper with background, padding, and styling
- Columns - Multi-column layouts (2-4 columns)
- Table Layout - Grid-based layout system
- Divider - Horizontal separator line
- Spacer - Vertical spacing control
Content Components
Display text, images, and static content:
- Text - Simple paragraph text
- Heading - Headings (H1-H6)
- Rich Text - Formatted HTML content
- Image - Images with responsive sizing
- List - Ordered and unordered lists
- HTML Fragment - Custom HTML with CSS
Data Components
Display and manipulate data:
- Table - Data tables with 5 column types
- Chart - Visualizations (PDF + Excel)
- Loop - Repeat content for arrays
- Conditional - Show/hide based on conditions
Interactive Components
PDF-specific interactive elements:
- Button - Call-to-action buttons (links in PDFs)
- QR Code - QR codes for tickets, URLs, etc.
- Timeline - Status progression timeline
Template Type Support
| Component | Excel | Notes | |
|---|---|---|---|
| Rich Text | ✅ | ✅ | Primary text component (recommended) |
| Text | ✅ | ✅ | Basic text (deprecated - use Rich Text) |
| Heading | ✅ | ✅ | H1-H6 headings (deprecated - use Rich Text) |
| Button | ✅ | ❌ | PDF only (clickable links) |
| Image | ✅ | ✅ | Responsive images |
| Container | ✅ | ✅ | Layout wrapper |
| Columns | ✅ | ✅ | Multi-column layouts |
| List | ✅ | ✅ | Ordered/unordered lists |
| Table | ✅ | ✅ | Data tables |
| Table Layout | ✅ | ✅ | Grid layout |
| Divider | ✅ | ✅ | Horizontal line |
| Spacer | ✅ | ✅ | Vertical spacing |
| Chart | ✅ | ✅ | Data visualizations (rendered images in PDFs, native in Excel) |
| Loop | ✅ | ✅ | Iterate over arrays |
| Conditional | ✅ | ✅ | Conditional rendering |
| QR Code | ✅ | ❌ | PDF only (scannable codes) |
| Barcode | ✅ | ❌ | PDF only (Code128, EAN, UPC, etc.) |
| Timeline | ✅ | ❌ | PDF only (status progression) |
| HTML Fragment | ✅ | ✅ | Custom HTML/CSS |
The text and heading components are deprecated. Use rich-text instead for all text content.
Layout Components
Container
Wrapper component with background, padding, and styling. Use to group and style related content.
Properties
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
backgroundColor | string | No | transparent | Background color (hex, rgb, rgba, named) |
padding | string | No | "0px" | CSS padding value (e.g., "20px", "10px 20px") |
maxWidth | string | No | none | Maximum width (e.g., "600px", "100%") |
borderRadius | string | No | "0px" | Border radius (e.g., "8px", "50%") |
border | string | No | none | CSS border value (e.g., "1px solid #000") |
align | enum | No | left | Alignment: "left", "center", "right" |
margin | string | No | "0px" | CSS margin value |
children | array | No | [] | Child components |
Example
{
"type": "container",
"id": "welcome-section",
"props": {
"backgroundColor": "#f8f9fa",
"padding": "40px 20px",
"maxWidth": "600px",
"borderRadius": "8px",
"align": "center"
},
"children": [
{
"type": "heading",
"id": "welcome-heading",
"props": { "level": 1 },
"content": "Welcome {{userName}}!",
"style": { "textAlign": "center" }
},
{
"type": "text",
"id": "welcome-text",
"content": "Thanks for joining us. Your account is ready.",
"style": { "textAlign": "center" }
}
]
}
Use Cases
- Group related content with consistent styling
- Create card-like sections in documents
- Add background colors to highlight sections
- Control maximum width for better readability
Columns
Multi-column layout component for side-by-side content (2-4 columns).
Properties
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
columnCount | number | No | 2 | Number of columns (1-4) |
gap | string/number | No | "20px" | Gap between columns |
columnWidths | array | No | equal | Array of width values (e.g., ["50%", "50%"]) |
backgroundColor | string | No | transparent | Background color |
padding | string | No | "0px" | CSS padding value |
verticalAlign | enum | No | top | Alignment: "top", "middle", "bottom" |
stackOnMobile | boolean | No | true | Stack columns on small screens |
children | array | No | [] | Child components (one per column) |
Example
{
"type": "columns",
"id": "feature-columns",
"props": {
"columnCount": 3,
"gap": "20px",
"stackOnMobile": true
},
"children": [
{
"type": "container",
"id": "feature-1",
"props": { "padding": "20px", "align": "center" },
"children": [
{
"type": "image",
"id": "icon-1",
"props": {
"source": "https://example.com/icon1.png",
"width": 64,
"height": 64,
"alignment": "center"
}
},
{
"type": "heading",
"id": "title-1",
"props": { "level": 3 },
"content": "Fast Delivery",
"style": { "textAlign": "center" }
},
{
"type": "text",
"id": "desc-1",
"content": "Same-day shipping available",
"style": { "textAlign": "center" }
}
]
},
{
"type": "container",
"id": "feature-2",
"props": { "padding": "20px", "align": "center" },
"children": [
{
"type": "image",
"id": "icon-2",
"props": {
"source": "https://example.com/icon2.png",
"width": 64,
"height": 64,
"alignment": "center"
}
},
{
"type": "heading",
"id": "title-2",
"props": { "level": 3 },
"content": "Secure Payment",
"style": { "textAlign": "center" }
},
{
"type": "text",
"id": "desc-2",
"content": "SSL encrypted checkout",
"style": { "textAlign": "center" }
}
]
},
{
"type": "container",
"id": "feature-3",
"props": { "padding": "20px", "align": "center" },
"children": [
{
"type": "image",
"id": "icon-3",
"props": {
"source": "https://example.com/icon3.png",
"width": 64,
"height": 64,
"alignment": "center"
}
},
{
"type": "heading",
"id": "title-3",
"props": { "level": 3 },
"content": "24/7 Support",
"style": { "textAlign": "center" }
},
{
"type": "text",
"id": "desc-3",
"content": "Always here to help",
"style": { "textAlign": "center" }
}
]
}
]
}
Use Cases
- Feature lists with icons
- Side-by-side product comparisons
- Contact information with labels and values
- Multi-column layouts in newsletters
Table Layout
Grid-based layout component (different from data tables). Creates a fixed grid for positioning components.
Properties
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
rows | number | No | 1 | Number of rows (1-20) |
cols | number | No | 1 | Number of columns (1-10) |
borderWidth | string | No | "0px" | Border width (e.g., "1px") |
borderColor | string | No | #000000 | Border color |
cellPadding | string | No | "0px" | CSS padding for each cell |
cellBackgroundColor | string | No | transparent | Background color for cells |
cellAlign | enum | No | left | Cell alignment: "left", "center", "right" |
cellVerticalAlign | enum | No | top | Vertical alignment: "top", "middle", "bottom" |
borderCollapse | boolean | No | true | Collapse borders between cells |
width | string | No | 100% | Table width |
children | array | No | [] | Child components (one per cell) |
Example
{
"type": "table-layout",
"id": "info-grid",
"props": {
"rows": 2,
"cols": 2,
"borderWidth": "1px",
"borderColor": "#e0e0e0",
"cellPadding": "10px",
"width": "100%"
},
"children": [
{
"type": "text",
"id": "label-1",
"content": "Order Number:",
"style": { "fontWeight": "bold" }
},
{
"type": "text",
"id": "value-1",
"content": "{{orderNumber}}"
},
{
"type": "text",
"id": "label-2",
"content": "Order Date:",
"style": { "fontWeight": "bold" }
},
{
"type": "text",
"id": "value-2",
"content": "{{orderDate}}"
}
]
}
Use Cases
- Form-like layouts (label + value pairs)
- Invoice headers with structured data
- Fixed grid positioning for components
- Simple data displays without table headers
Divider
Horizontal separator line for visual separation.
Properties
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
style | enum | No | solid | Line style: "solid", "dashed", "dotted" |
thickness | number | No | 1 | Line thickness in pixels (1-10) |
color | string | No | #e0e0e0 | Line color |
width | string | No | 100% | Divider width (e.g., "80%", "600px") |
margin | string | No | 20px 0 | CSS margin value |
Example
{
"type": "divider",
"id": "section-divider",
"props": {
"style": "solid",
"thickness": 2,
"color": "#cccccc",
"width": "80%",
"margin": "30px 0"
}
}
Use Cases
- Separate sections in documents
- Visual breaks between content blocks
- Footer separators
- Section headers
Spacer
Vertical spacing component for controlling whitespace.
Properties
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
height | string/number | No | 20px | Vertical spacing (e.g., "40px", 60) |
Example
{
"type": "spacer",
"id": "section-spacing",
"props": {
"height": "40px"
}
}
Use Cases
- Add vertical spacing between sections
- Control whitespace in layouts
- Improve readability with breathing room
- Consistent spacing throughout template
Content Components
Text
Simple paragraph text component for body content.
Properties
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
content | string | Yes | - | Text content (supports {{variables}}) |
style | object | No | - | Styling options |
style.fontSize | number | No | 16 | Font size (6-72) |
style.fontWeight | string/number | No | normal | Weight: "normal", "bold", "bolder", "lighter", 100-900 |
style.color | string | No | #000000 | Text color |
style.backgroundColor | string | No | transparent | Background color |
style.textAlign | enum | No | left | Alignment: "left", "center", "right", "justify" |
style.lineHeight | string/number | No | 1.5 | Line height |
position | object | No | - | Position in attachment (x, y coordinates) |
Example
{
"type": "text",
"id": "intro-text",
"content": "Hello {{userName}}, your order #{{orderNumber}} has been confirmed!",
"style": {
"fontSize": 16,
"color": "#333333",
"textAlign": "left",
"lineHeight": 1.6
}
}
Use Cases
- Body paragraphs
- Descriptions
- Explanatory text
- Dynamic content with variables
Heading
Heading component for section titles (H1-H6).
Properties
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
content | string | Yes | - | Heading text (supports {{variables}}) |
level | number | Yes | 1 | Heading level (1-6) |
style | object | No | - | Styling options (same as Text) |
position | object | No | - | Position in attachment (x, y coordinates) |
Example
{
"type": "heading",
"id": "page-title",
"props": {
"level": 1
},
"content": "Order Confirmation",
"style": {
"fontSize": 32,
"fontWeight": "bold",
"color": "#007bff",
"textAlign": "center"
}
}
Use Cases
- Page titles
- Section headings
- Document title headings
- Hierarchical content structure