Interaction
JS behaviour
Compare slider
Before and after images split by a draggable divider; a real range sits underneath (keyboard and screen readers for free), clip-path does the cut, RTL is handled and it can split vertically.
Real scenarios
The component as it is used in a product — not a specimen grid.
A photo editor’s before/after
Drag anywhere on the photo (or Tab to it and use the arrows, Home, End). Underneath is a real range input, so wire:model keeps the split in Livewire state.
Redesign review, top to bottom
orientation="vertical": the old landing page above the line, the new one below.
Right to left
“Before” sits at the inline start — the right — and the range maps right to left natively.
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| before / after | array | [] | Each takes src and alt. |
| value / wire:model | float | 50 | Where the divider sits from the inline start (or the top), 0–100; wire:model lands on the range. |
| orientation | string | 'horizontal' | horizontal or vertical. |
| beforeLabel / afterLabel | string | 'Before' / 'After' | The corner tags. |
Snippet
<x-nx::compare-slider :before="['src' => $raw, 'alt' => 'خام']" :after="['src' => $graded, 'alt' => 'اصلاحرنگشده']"
before-label="قبل" after-label="بعد" wire:model.live="split" />