Media Fancy Stable

Compare

Before/after image comparison slider with hover and drag modes

Preview

Installation

pnpm add fancy-ui-svelte
import { Compare } from 'fancy-ui-svelte'

Usage

svelte
<script lang="ts">
  import { Compare } from 'fancy-ui-svelte';
</script>

<Compare />

Examples

Basic Usage

Hover mode comparison.

Drag Mode

Click and drag to control.

Autoplay

Automatic animation.

Custom Content

Use snippets instead of images.

Props

PropTypeDefaultDescription
firstImage string""URL of the first (left) image
secondImage string""URL of the second (right) image
firstImageAlt string"First image"Alt text for the first image
secondImageAlt string"Second image"Alt text for the second image
firstContentClass string""CSS classes for the first content container
secondContentClass string""CSS classes for the second content container
initialSliderPercentage number50Initial slider position (0-100)
slideMode "hover" | "drag""hover"How the slider is controlled
showHandlebar booleantrueShow the drag handle bar
autoplay booleanfalseAutomatically animate the slider back and forth
autoplayDuration number5000Duration of one autoplay cycle in ms

Slots

SlotDescription
firstContentCustom content to render in the first (left) panel instead of an image
secondContentCustom content to render in the second (right) panel instead of an image
handleCustom drag handle element