# Using Conditional Content


Use Dyspatch's Conditional Display feature to dynamically add content to your
emails and control what users see.

## Using Conditional Display

You can use Conditional Display on any block in Dyspatch. Select the block in the email preview and click the **"Display Options"** tab to bring up the conditional builder:

![Arrow showing location of the Display Options tab](https://docs.dyspatch.io/img/emails/display-options-tab.png)

From here you can write a conditional statement for when the block should show.
For example, say you only wanted to show a specific block to your gold-tier
users. You would need to create a condition that looks something like this:

![Example of user_type of "gold" in the conditional display ui](https://docs.dyspatch.io/img/emails/gold-tier-condition.png)

In this example the block will only show when the `user_type` variable is equal
to the word "gold". You can use similar strategies to set up multiple blocks
that get shown for different user types. For example, you could set up a block
to appear for "silver" tier users.

To help you keep track of which block is using a conditional display Dyspatch
will add a "Conditional" tag when you mouse over the block:

![Display tag example](https://docs.dyspatch.io/img/emails/conditional-display-tag.png)

## Conditional Content in Subject and Preheader Fields

DML conditionals can be used directly in the **Subject** and **Preheader** fields of a template. This lets you tailor the subject line or preview text based on data variables — without needing to create separate templates.

Conditional logic in these fields uses the same <a href="https://docs.dyspatch.io/dml/#dys-if" target="_blank">DML conditional syntax</a> available in DML blocks.

For example, to show a different subject line based on a user's membership tier:

```
<dys-if-else><dys-if cond="user_type == 'gold'">Your exclusive Gold member offer inside</dys-if><dys-else>Check out what's new this week</dys-else></dys-if-else>
```

The same patterns work in the **Preheader** field. This example includes an else fallback if the `first_name` data isn't present:

```
<dys-if-else><dys-if cond="first_name != nil">Hi @{first_name}, here's something just for you</dys-if><dys-else>Here's something just for you</dys-else></dys-if-else>
```

<div class="highlight tip">In DML conditionals, <code>== nil</code> matches falsy or missing values (for example: undefined variables, <code>null</code>, empty string, <code>0</code>, <code>false</code>, empty arrays, and empty objects). Use <code>!= nil</code> to require a truthy value.</div>

For a full reference of supported operators and keywords (such as `nil`, `&&`, `||`, and `in`), see the <a href="https://docs.dyspatch.io/dml/#dys-if" target="_blank">DML conditionals documentation</a>.

## Tips and Tricks

Conditional blocks are an incredibly useful tool when building out your emails.
Here are some tips and ideas to make the most of the feature:

- Combine with [Customer Profiles](/emails/using_customer_profiles/) or [Preview Data](/emails/testing_your_email_with_preview_data/) to quickly test with different data variations

- Empower your team to use conditional blocks instead of creating one-off code
  blocks in DML

- Display targeted content to specific users to increase conversions

- Use it when A/B testing! One group of users sees Block A, the other Block B
