Document Stack
Document Stack
Docs

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:

  1. Select the element on the canvas
  2. In the inspector panel, find the Visibility section
  3. Click Add Condition
  4. Set the field key, operator, and value

Operators

OperatorDescriptionExample
equalsExact matchstatus equals paid
not equalsDoes not matchstatus not equals draft
is emptyField has no valuenotes is empty
is not emptyField has any valuediscount_code is not empty
containsValue includes textcountry contains US
greater thanNumeric comparisontotal greater than 1000
less thanNumeric comparisontotal less than 100

Example: "PAID" Badge

Create a green "PAID" badge that only appears when the invoice is paid:

  1. Add a Text element with the text "PAID"
  2. Style it with a green background, white text, and rounded corners
  3. In Visibility, set: status equals paid
JSON
// 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:

  1. Add a Text element with "Notes:" as a label
  2. Add a Field element with key notes
  3. Set both elements' visibility to: notes is 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: status equals paid
  • Condition 2: total greater than 1000

Boolean Fields

For simple show/hide toggles, use boolean values in your data:

JSON
{
  "data": {
    "show_discount": true,
    "show_tax_details": false,
    "show_footer_note": true
  }
}

Set the visibility condition to: show_discount equals true

Hidden elements don't appear in the generated PDF at all — they don't leave blank space. Other elements don't automatically shift to fill the gap, since Document Stack uses absolute positioning.

Next Steps