Media · Gutenberg

Before/After Slider block for WordPress

Compare two images with a draggable slider handle.

Get Blockenberg

Free Gutenberg block in Blockenberg. The inspector controls and front-end behavior on this page come from this block’s source, not a shared stub.

Get Blockenberg

What it actually does

Compare two images with a draggable slider handle.

Inspector panels on this block: Images, Slider, Labels, Handle, Frame. Those titles come from index.js, not from a shared template.

Behavior controls: “Orientation” options: Horizontal, Vertical; “Aspect ratio” options: Auto, 1:1, 4:3, 3:2, 16:9; “Label position” options: Top, Bottom; “Handle style” options: Circle, Square.

Where to find it

Gutenberg inserter → Media → search “Before/After Slider” (block name `blockenberg/before-after` in block.json). Style it in the sidebar after insert.

How to use Before/After Slider block for WordPress

  1. Install Blockenberg. Install from WordPress.org and activate the plugin.
  2. Insert the block. Edit a page, click +, search for “Before/After Slider”, insert it. Category: Media.
  3. Configure inspector controls that exist on this block. Open Images. Set “Orientation”, “Start position (%)”, “Minimum height (px)”, “Aspect ratio”.
  4. Check the published page. The view script reads HTML data attributes: data-orientation, data-pos. The block editor preview may not run the same view script.

Inspector controls from this block’s code

ControlWhat the code does
OrientationSelect control; the chosen value is saved on the block. Options: Horizontal; Vertical. block.json default: horizontal. Saved as `orientation`.
Start position (%)Numeric range control in the inspector. Range 0–100. block.json default: 50. Saved as `startPosition`.
Minimum height (px)Numeric range control in the inspector. Range 120–900. block.json default: 260. Saved as `minHeight`.
Aspect ratioSelect control; the chosen value is saved on the block. Options: Auto; 1:1; 4:3; 3:2; 16:9; 21:9. block.json default: auto. Saved as `aspect`.
Show labelsOn/off toggle in the inspector. On by default. Saved as `showLabels`.
Label positionSelect control; the chosen value is saved on the block. Options: Top; Bottom. block.json default: top. Saved as `labelPosition`.
Before labelText field in the inspector. block.json default: Before. Saved as `beforeLabel`.
After labelText field in the inspector. block.json default: After. Saved as `afterLabel`.
Label radiusNumeric range control in the inspector. Range 0–30. block.json default: 6. Saved as `labelRadius`.
Handle styleSelect control; the chosen value is saved on the block. Options: Circle; Square. block.json default: circle. Saved as `handleStyle`.
Handle sizeNumeric range control in the inspector. Range 28–80. block.json default: 44. Saved as `handleSize`.
Handle icon sizeNumeric range control in the inspector. Range 10–34. block.json default: 18. Saved as `handleIconSize`.
Divider line widthNumeric range control in the inspector. Range 1–8. block.json default: 2. Saved as `lineWidth`.
Animate handleOn/off toggle in the inspector. Off by default. Saved as `handleHoverAnim`.
AnimationSelect control; the chosen value is saved on the block. Options: Pulse; Wiggle; Bounce; Glow. block.json default: pulse. Saved as `handleHoverAnimType`.
Animation duration (ms)Numeric range control in the inspector. Range 150–2000. block.json default: 650. Saved as `handleHoverAnimDuration`.
Enlarge icon area on hoverOn/off toggle in the inspector. On by default. Saved as `handleHoverScale`.
Hover scaleNumeric range control in the inspector. Range 1–1.25. block.json default: 1.08. Saved as `handleHoverScaleAmount`.
Border radiusNumeric range control in the inspector. Range 0–40. block.json default: 12. Saved as `borderRadius`.
Frame — ShadowOn/off toggle in the inspector. Off by default. Saved as `shadow`.
LabelShared Blockenberg typography popover (family, size, weight, spacing). Saved as `labelTypo`.

What the front-end script actually does

When this is the right block

Notes from the implementation

viewScript: this folder’s frontend.js is enqueued on the front end for this block.

FAQ

How do I add the Before/After Slider block in WordPress?

Install Blockenberg from WordPress.org, edit a page in the block editor, click +, and search for “Before/After Slider”. It sits under Media. After insert, open Images and set “Orientation”, “Start position (%)”, “Minimum height (px)”, “Aspect ratio”.

What makes Before/After Slider different from other Blockenberg blocks?

Compare two images with a draggable slider handle. Inspector labels on this block include “Orientation”, “Start position (%)”, “Minimum height (px)”, “Aspect ratio”.

Is the Before/After Slider Gutenberg block free?

Yes. Before/After Slider ships inside Blockenberg. Get the plugin from WordPress.org — no paid add-on is required for this block.

Can I style Before/After Slider to match my theme?

Yes. Blockenberg’s shared typography and color panels apply here, plus any block-specific style controls listed on this page (panels: Images, Slider, Labels, Handle).

Related media blocks

Get Blockenberg

Install Blockenberg from WordPress.org, then insert Before/After Slider from the Gutenberg inserter.

Get Blockenberg