Media Fancy Stable

Compare

.md

Before/after image comparison slider split by a blade of light: a white-hot seam with a chromatic fringe, pulses running along it and a trail that stretches with the speed of the gesture

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.

Beam Colors

Tint the seam with your own colours.

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
beamColors string[]["#22d3ee", "#818cf8", "#f472b6"]Beam colours: left fringe, centre, right fringe (one or more colours)
label string"Comparison slider"Accessible name of the slider

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