Installation
npx kinetic-ui-cli@latest add before-after-slider
How It Works
The BeforeAfterSlider relies on a pure CSS clip-path: inset(...) to perfectly mask the foreground image. State tracking for mouse and touch events dynamically updates the position of the clip-path mask and the slider handle in real time without lag.
Usage Guide
1. Import the Component
Import the component into your React or Next.js page:
import { BeforeAfterSlider } from "@/components/creative/before-after-slider";
2. Implementation Example
Render the component and customize its behavior by passing props:
import { BeforeAfterSlider } from "@/components/creative/before-after-slider";
export default function Example() {
return (
<div className="w-full flex items-center justify-center p-8">
<BeforeAfterSlider
beforeImage="example"
afterImage="example"
/>
</div>
);
}