Adding a before-after image slider to your website usually means finding a JavaScript library, reading through documentation, and spending time on setup and styling. There is a much faster way. You can drop one into any website with a single HTML attribute - no code to write, no plugins to install.
The slider above is a live demo. Drag the handle to compare both images. That exact component can be on your site in about 30 seconds.
What is a before-after slider?
A before-after slider (also called an image comparison slider) lets visitors drag a divider between two images to see the difference. The first image sits behind the second, and the divider reveals more or less of each side as you drag.
Common use cases:
- Photo retouching and editing portfolios
- Home renovation and interior design showcases
- Product comparisons
- Website redesign presentations
- Dental, cosmetic, or fitness transformations
Instead of placing two images side by side and hoping visitors spot the difference, a slider makes the comparison interactive. Users control what they see, which keeps them on the page longer.
How do you add a before-after slider to a website?
Two steps. First, add the OneType Transforms script tag to your site. This is one line you paste in your HTML:
<script src="https://cdn.transforms.onetype.ai/script/57095981335841558d328d599e6f5322.js"></script>Second, add two images inside a div with the ot="before-after" attribute:
<div ot="before-after">
<img src="before.jpg" alt="Before">
<img src="after.jpg" alt="After">
</div>That is it. The first image becomes the "before" side, the second becomes the "after" side. The slider handle, divider line, and drag behavior all appear automatically. No CSS to write, no JavaScript to configure.
Can you customize the before-after slider?
Yes. Everything is controlled through HTML attributes - just add them to the same div. Here are all the options:
Starting position - control where the slider starts. Default is 50 (middle). Set it to any value between 0 and 100:
<div ot="before-after" ot-position="30">Vertical mode - slide top to bottom instead of left to right. Useful for landscape images or when the change happens vertically:
<div ot="before-after" ot-direction="vertical">Labels - add text labels to each side so visitors know which is which:
<div ot="before-after" ot-label-before="Original" ot-label-after="Edited">Hover mode - instead of dragging, the slider follows the mouse cursor. Good for portfolios where you want instant interaction without clicking:
<div ot="before-after" ot-hover="true">You can combine all of these together:
<div ot="before-after" ot-direction="vertical" ot-label-before="Before" ot-label-after="After" ot-position="30" ot-hover="true">
<img src="before.jpg" alt="Before">
<img src="after.jpg" alt="After">
</div>Does it work on Webflow, WordPress, and Shopify?
Yes. It works on any website that lets you add custom HTML. Here is a quick overview for the most popular platforms:
Webflow
Paste the script tag in Site Settings > Custom Code > Footer Code. Then add an Embed element to your page and paste the before-after HTML. Requires a Basic plan ($14/mo) or higher. Full Webflow guide.
WordPress
Install the free WPCode plugin and paste the script tag in Header & Footer > Header. Then use a Custom HTML block in the editor for the slider. Works on any self-hosted WordPress site. Full WordPress guide.
Squarespace
Add the script tag in Website > Website Tools > Code Injection > Header. Use a Code Block (set to HTML, Display Source off) for the slider markup. Requires a Core plan ($23/mo) or higher. Full Squarespace guide.
Shopify
Add the script tag in theme.liquid before </head>. Then use a Custom Liquid section in the theme editor for the slider HTML. Works on Basic plan ($39/mo) and up. Full Shopify guide.
Framer
Add the script tag in Settings > General > Custom Code > End of head tag. Use an Embed component for the slider HTML. Requires a Basic plan ($10/mo) or higher. Full Framer guide.
The same approach works on Elementor, Wix, static HTML sites, or any platform where you can add custom code.
Is the before-after slider free?
Yes. The before-after slider is completely free. No account needed, no token, no restrictions. Just add the script tag and use it.
It is part of OneType Transforms - a collection of drop-in interactive components for websites. Some transforms are free (like this one), and there are premium ones too. The Pro plan is a one-time $149 payment with lifetime updates. No subscription.
Does the slider work on mobile?
Yes. It uses a native range input under the hood, so touch dragging on phones and tablets works out of the box. It also supports keyboard navigation and screen readers for accessibility.
The images scale to fit their container, so the slider is responsive by default. It looks the same on a 4K monitor and a phone screen.
Get started
Grab the script tag from transforms.onetype.ai/get-started, paste it into your site, and add a before-after slider anywhere with the ot="before-after" attribute. Free, no account needed.
Want to see all available transforms? Browse the full collection at transforms.onetype.ai.






