Conditional Content
Show or hide template elements based on data conditions for dynamic documents.
Overview
Conditional content lets you show or hide elements in your template based on the data you pass at generation time. This means a single template can produce different-looking documents depending on the data.
Examples:
- Show a "PAID" badge only when the invoice is paid
- Display a discount line only when a discount code is applied
- Show different footer text for domestic vs. international orders
- Hide an optional notes section when no notes are provided
Setting Visibility Conditions
To make an element conditional:
- Select the element on the canvas
- In the inspector panel, find the Visibility section
- Click Add Condition
- Set the field key, operator, and value
Operators
| Operator | Description | Example |
|---|---|---|
| equals | Exact match | status equals paid |
| not equals | Does not match | status not equals draft |
| is empty | Field has no value | notes is empty |
| is not empty | Field has any value | discount_code is not empty |
| contains | Value includes text | country contains US |
| greater than | Numeric comparison | total greater than 1000 |
| less than | Numeric comparison | total less than 100 |
Example: "PAID" Badge
Create a green "PAID" badge that only appears when the invoice is paid:
- Add a Text element with the text "PAID"
- Style it with a green background, white text, and rounded corners
- In Visibility, set:
statusequalspaid
// This data shows the badge:
{
"data": {
"status": "paid",
"invoice_number": "INV-001"
}
}
// This data hides the badge:
{
"data": {
"status": "pending",
"invoice_number": "INV-002"
}
}Example: Optional Notes
Show a "Notes" section only when notes are provided:
- Add a Text element with "Notes:" as a label
- Add a Field element with key
notes - Set both elements' visibility to:
notesis not empty
Group Conditions
When you want to show/hide multiple related elements together (like a label and its value), apply the same visibility condition to all of them.Multiple Conditions
You can add multiple conditions to a single element. All conditions must be true for the element to be visible (AND logic).
For example, show a "VIP" badge only for paid invoices over $1,000:
- Condition 1:
statusequalspaid - Condition 2:
totalgreater than1000
Boolean Fields
For simple show/hide toggles, use boolean values in your data:
{
"data": {
"show_discount": true,
"show_tax_details": false,
"show_footer_note": true
}
}Set the visibility condition to: show_discount equals true
Next Steps
- Data Binding — Fundamentals of dynamic data
- Calculated Fields — Compute values from data
- Field Elements — Dynamic text fields