Skip to content
Data Display

Comparison Slider

Drag a divider to reveal a before/after comparison of two layers.

Import

tsx
import { ComparisonSlider } from "@cooud-ui/ui";
bash
npx cooud-ui add comparison-slider

Examples

API Reference

Generated from the component's exported types.

ComparisonSliderProps

Extends Omit<HTMLAttributes<HTMLDivElement>, "onChange">

PropTypeDefaultDescription
before*
ReactNodeContent shown on the left, revealed by the clip (typically the "before" image).
after*
ReactNodeContent shown as the full base layer (typically the "after" image).
defaultPosition
number50Initial divider position as a percentage (0–100). Uncontrolled.
position
numberControlled divider position as a percentage (0–100).
onPositionChange
(position: number) => voidCalled with the next position when the divider moves.
aria-label
stringAccessible name for the divider handle.