Hooks
Docs Hooks Editor filters · JavaScript
modalKit.pickerPreview
filter
Free
JavaScript
Turn on the template picker’s live preview of the selected starter, with a Desktop / Mobile switch. Off in Free; Modal Kit Pro turns it on.
The template picker opens for a new modal and from Change template on the Modal block’s toolbar and block menu. It’s part of Free’s modal-kit-editor script on the block editor for a modal, and asks this filter each time it renders.
When the filter returns a truthy value, selecting a starter opens a pane beside the grid with a live preview, a Desktop / Mobile switch, the starter’s details and Use template. The pane isn’t shown for the Pro samples category.
Parameters
Parameter
Description
show
bool
false by default.
Returns
bool Whether to show the preview pane.
Examples
Turn the preview on
import { addFilter } from '@wordpress/hooks';
addFilter( 'modalKit.pickerPreview', 'my-plugin/preview', () => true );
Only on wide screens
Keeps the grid roomy on laptops, and keeps the pane if another plugin turned it on.
import { addFilter } from '@wordpress/hooks';
addFilter(
'modalKit.pickerPreview',
'my-plugin/preview-wide',
( show ) => show || window.innerWidth >= 1440
);
Good to know
The value isn’t cast: any truthy value shows the pane.
The preview renders the starter’s blocks with the Modal block’s editor view, so canvas chrome from modalKit.canvasChrome appears in it unless it checks isPreviewMode.
Applied in modal-kit/src/editor/pattern-picker/index.js.