<p>Craft's Request service has a built-in method for this, <a href="https://craftcms.com/docs/templating/craft.request#isLivePreview" rel="noreferrer"><code>isLivePreview</code></a>.</p>

<p>Here's how to only display content in the live preview view:</p>

<pre><code>{% if craft.request.isLivePreview %}
    &lt;p&gt;Only appears in live preview.&lt;/p&gt;
{% endif %}
</code></pre>

CC BY-SA 3.0
2017-04-06T17:07:06.713Z
Spot on. Cheers.
ianp
CC BY-SA 3.0
2017-04-06T16:19:45.607Z
2017-04-06T16:19:45.607Z
Stephen Lewis
<p>Is there any way of adding a class onto a page body when it is viewed within the 'live preview' pane?</p>

<p>I can then use this to make things either show or not show.</p>

<p>I want to do this to highlight specific things to content editors that I don't feel are worth highlighting to regular users.</p>

<p>I think I can only do this by hanging rules off a special 'preview only' class.</p>

<live-preview>
Apply different classes and styles when in 'live preview' pane
# Apply different classes and styles when in 'live preview' pane

(Asked by: username_0 on 2017-04-06)

Is there any way of adding a class onto a page body when it is viewed within the 'live preview' pane?

I can then use this to make things either show or not show.

I want to do this to highlight specific things to content editors that I don't feel are worth highlighting to regular users.

I think I can only do this by hanging rules off a special 'preview only' class.

**Tags:** live-preview


---

## 1 answers

### Answer by username_1 on 2017-04-06. Score: 5 | Accepted answer

Craft's Request service has a built-in method for this, isLivePreview.
Here's how to only display content in the live preview view:
{% if craft.request.isLivePreview %}
    Only appears in live preview.
{% endif %}

> **Comments:**
> **username_0**: Spot on. Cheers.  

---

