Live Preview

The Live Preview feature lets you see what an entry will look like on the front-end of your site as you edit it.

Customizing how an entry is rendered

Out of the box, Statamic will push the temporary version of the entry through its usual render process.

If you have complex requirements – for example, needing to render it through a different frontend – you are able to customize it.

The Entry class has a toLivePreviewResponse method. You can override this and return whatever you want to be rendered in Live Preview’s content pane.

See how to override the entry classes.

namespace App;
use Statamic\Entries\Entry;
class YourCustomEntry extends Entry
public function toLivePreviewResponse($request, $extra)
return response('any html');

The localized entry (eg. $this) will have any temporary values entered in Live Preview applied as supplemented data.

$this->get('title'); // the original title
$this->getSupplement('title'); // the title as entered in live preview
$array = $this->toArray(); // when converting an entry to an array, the supplemental data overrides the originals
$array['title']; // this would be the title as entered in live preview

The $request provided to the toLivePreviewResponse method will be a faked request to either the entry’s absolute or AMP URL, depending on what the user has selected.

The $extra parameter will be an array of the values for any additional inputs.

Additional Inputs

You may add extra fields to Live Preview’s header area using custom Vue components. The values of these fields will be available in the cascade.

Define the inputs using an array of key value pairs of field handles and vue component names in config/statamic/live_preview.php:

'inputs' => [
'show_ads' => 'live-preview-ads',

Similar to fieldtypes, this component will be given a value prop, and expect any changes to emit an input event.

Statamic.$components.register('live-preview-ads', require('./LivePreviewAds.vue'));
<input type="checkbox"
@input="$emit('input', $" />
Show Advertisements
export default {
props: ['value']

You can use these values in your views under the live_preview array:

{{ if live_preview:show_ads }}
<div class="ad"> ... </div>
{{ /if }}


Prop Description
value The value of the input.
loading Whether the live preview contents is being loaded. (eg. when you type)
Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →