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.
| Prop | Type | Default | Description |
|---|---|---|---|
| before | ReactNode | Content shown on the left of the handle. Usually an image. | |
| after | ReactNode | Content shown on the right of the handle. Usually an image. | |
| beforeLabel | string | "Before" | Label for the before side. |
| afterLabel | string | "After" | Label for the after side. |
| value | number | Handle position from 0 to 100. Set it to control the component. | |
| defaultValue | number | 50 | Starting handle position when uncontrolled. |
| onValueChange | (value: number) => void | Called with the new position (0 to 100). | |
| aspectRatio | string | "16 / 10" | Width to height ratio of the frame. |
| aria-label | string | "Compare before and after" | Accessible name of the slider. |
| className | string | Extra classes added to the outer element. |