Before/After Slider is a drag-to-compare block that stacks two images in the same frame and lets visitors reveal either side by moving a handle. Use it for product comparisons, photo retouching demos, design before/after — any two states of the same subject.
How to add
Open the block inserter, switch to the Axiom Blocks category, and click Before/After Slider. The block drops in as a placeholder. Set both images in the sidebar to activate the slider.
Images
The Images panel has two independent pickers — Before and After. Each shows a thumbnail preview once an image is selected.
- Select image — opens the media library
- Replace — swaps the current image without losing other settings
- Remove — clears the image and returns to the placeholder state
The block renders nothing on the frontend until both images are set.
Labels
Enable Show labels to overlay a text chip on each side of the frame.
- Before label — defaults to
Before - After label — defaults to
After
Labels are hidden by default. When disabled, neither label field appears in the sidebar. Their color, background, typography, and corner radius live in Styles → Labels.
Behavior
Orientation
- Horizontal — the divider runs vertically and moves left/right. The default.
- Vertical — the divider runs horizontally and moves up/down, revealing the after image from the top. Useful for tall subjects — a full-length photo retouch, a landing page redesign.
Interaction
- Drag — the visitor presses and pulls the handle. The default, and the right choice on touch.
- Hover — the handle follows the pointer as it passes over the image, no click needed. Feels immediate on desktop, but has no touch equivalent, so the slider stays draggable on phones either way.
Slider
Initial position
Where the handle starts when the block loads, as a percentage from the left (or from the top, in vertical orientation). Default is 50. Set it lower to reveal more of the After image on load, higher to reveal more of the Before image.
Aspect ratio
Controls the frame's height.
| Option | Behavior |
|---|---|
| Auto (use before image) | Frame height matches the before image's natural proportions |
| 16 : 9 | Fixed widescreen ratio |
| 4 : 3 | Fixed standard ratio |
| 1 : 1 | Square |
| 3 : 4 | Fixed portrait ratio |
When a fixed ratio is set, both images fill the frame with object-fit: cover.
The sidebar at a glance
The block sidebar is split into two tabs. Settings is what the slider does; Styles is how it looks, organised by the parts you can see.
| Tab | Section | Covers |
|---|---|---|
| Settings | Images | Before and After image pickers |
| Settings | Labels | Show labels, label text |
| Settings | Behavior | Orientation, interaction |
| Settings | Slider | Initial position, aspect ratio |
| Settings | Advanced | Visibility, Position, anchor, CSS class |
| Styles | Container | The frame around both images |
| Styles | Labels | The two overlay chips |
| Styles | Handle | The drag handle and divider line |
| Styles | Spacing | Padding and margin on the outer wrapper |
Styling
| Part | Rows |
|---|---|
| Container | Border, Radius, Shadow, Max width (per device) |
| Labels | Text, Background, Typography, Radius |
| Handle | Handle color, Line color |
The Handle and Line colors default to white. Set them to something contrasting if your images are light near the center — a white handle on a bright sky is invisible.
The block supports Wide and Full alignment from the toolbar and an HTML anchor.
Interaction and accessibility
The slider works across pointer and touch devices. Dragging and click-to-jump both work regardless of the Interaction setting; Hover adds pointer tracking on top.
- Drag — press anywhere on the frame and pull to move the handle
- Click to jump — clicking a point on the frame snaps the handle there
- Keyboard — when the frame has focus:
| Key | Movement |
|---|---|
← / ↑ | −2% |
→ / ↓ | +2% |
Page Down / Page Up | ∓10% |
Home | Jump to 0% (full Before) |
End | Jump to 100% (full After) |
Both arrow pairs work in either orientation, so keyboard users are never stranded by the Vertical setting. The frame carries role="slider" and updates aria-valuenow on every move.
HTML output
The frame picks up is-aspect-auto instead of is-aspect-fixed when Aspect ratio is Auto (and no inline aspect-ratio), is-vertical only in vertical orientation, and is-hover only when Interaction is Hover.
CSS custom properties
The divider properties are set on .axiom-blocks-bas__frame; the styling properties are set on the outer wrapper.
| Property | Controls |
|---|---|
--slider-pos | Divider position (%); updated live by the frontend script |
--handle-color | Handle circle and chevron color |
--line-color | Divider line color |
--ab-bas-bs / --ab-bas-bc / --ab-bas-bw-* | Container border style, color, per-side width |
--ab-bas-radius-* | Container corner radius (tl, tr, br, bl) |
--ab-bas-shadow | Container box shadow |
--ab-bas-maxw | Container max width |
--ab-bas-label-color / --ab-bas-label-bg | Label text and background color |
--ab-bas-label-radius-* | Label corner radius |
--ab-bas-label-ff / -fw / -fs / -lh / -ls / -tt / -td / -ta | Label typography — family, weight, size, line height, letter spacing, transform, decoration, alignment |