X Enterprises
nuxt-x-affiliate

Compare Slider

Before / after image compare slider — draggable divider in horizontal or vertical orientation.

Compare Slider

The XAFCompareSlider component renders two images stacked with a draggable divider that reveals more or less of each. Useful for before/after shots, product comparison shots, day/night photography, and any visual A/B comparison.

Components

<XAFCompareSlider />

<XAFCompareSlider
  :before="{ src: '/img/before.jpg', alt: 'Without filter', label: 'Before' }"
  :after="{ src: '/img/after.jpg', alt: 'With filter', label: 'After' }"
/>

Props

PropTypeDefaultDescription
beforeCompareImagerequiredLeft/top image.
afterCompareImagerequiredRight/bottom image.
initialnumber50Initial slider position (0–100).
orientation'horizontal' | 'vertical''horizontal'Slider orientation.

Image shape

interface CompareImage {
  src: string
  alt: string
  label?: string
}

The divider is mouse- and touch-draggable. The handle button reports aria-label="Compare slider at {n}%" so screen readers can announce position changes on focus.


AI Context

component: XAFCompareSlider
package: "@xenterprises/nuxt-x-affiliate"
use-when: Before/after image compare slider with draggable divider, horizontal or vertical orientation.
Copyright © 2026