Comparison

A slider-based component for comparing two items in an overlay.

Installation

npx love-ui@latest add comparison

Usage

import { Comparison, ComparisonItem, ComparisonHandle } from "@/components/comparison"
<Comparison>
  <ComparisonItem>
    <img src="/before.jpg" alt="Before" />
  </ComparisonItem>
  <ComparisonHandle />
  <ComparisonItem>
    <img src="/after.jpg" alt="After" />
  </ComparisonItem>
</Comparison>

Features

  • Compare two items side by side with a draggable slider
  • Support for both hover and drag modes
  • Smooth animations
  • Touch and mouse event support
  • Customizable slider appearance
  • Responsive design that works with any content
  • Context provider for accessing comparison state

Examples

Hover mode

With event handlers