Compare slider

Drag a handle to reveal one thing over another, such as before and after photos. Works with images or any content, with pointer, touch and keyboard.

Install it the shadcn way: copy the source file into your project. It uses CSS 3D, Tailwind CSS v4 and Framer Motion, no WebGL.

CompareSlider3D props

PropTypeDefaultDescription
beforeReactNodeContent shown on the left of the handle. Usually an image.
afterReactNodeContent shown on the right of the handle. Usually an image.
beforeLabelstring"Before"Label for the before side.
afterLabelstring"After"Label for the after side.
valuenumberHandle position from 0 to 100. Set it to control the component.
defaultValuenumber50Starting handle position when uncontrolled.
onValueChange(value: number) => voidCalled with the new position (0 to 100).
aspectRatiostring"16 / 10"Width to height ratio of the frame.
aria-labelstring"Compare before and after"Accessible name of the slider.
classNamestringExtra classes added to the outer element.

More components

Guides

Start

Cards

Scenes

Controls & text

Buttons

More cards

UI elements

Form controls

App components

Text & backgrounds

Showpieces

Blocks