Skip to main content

Before / After

An image comparison slider — drag, hover or click to reveal the second image. Useful for retouching, renovations and product comparisons.

The block renders through the before_after element — the same PHP that runs in the page builder, so the front end is identical either way.

What the sidebar exposes

OptionWhat it does
before_imageThe base image
after_imageThe revealed image — use the same dimensions
type/comparison/designHandle and label look
type/comparison/orientationSplit horizontally or vertically
type/comparison/interactionDrag, hover or click to reveal
type/comparison/handle_sizeSize of the drag handle
type/comparison/show_labelsShow the Before / After labels
type/comparison/auto_introSweep the handle once on first view

Anything not listed stays available in the page builder, and round-trips untouched — the block only writes the values you change, so an element styled in the builder keeps every setting this sidebar does not show.

Both images are required

Until a Before and an After image are set, the block shows a placeholder rather than a broken slider.

The preview is inert, and must be

Left interactive, the slider's own pointer handlers would swallow the click that selects the block, and dragging the handle would become a Gutenberg block drag — the element and the editor fighting over the same gesture. The slider works normally on the front end.

Option paths look different here

This block's options are nested (type/comparison/design) rather than flat. That mirrors how the element stores them; the block reads and writes the same paths, so values are shared with the page builder either way.