Before-After Slider for Webflow - Step by Step

Want to add a before-after slider to your Webflow site? It takes about two minutes. No custom code to write - just a script tag and an Embed element with two images.
The slider above is a live demo. That exact component is what you will have on your Webflow site by the end of this guide.
What you need
- A Webflow site on a Basic plan or higher - the free Starter plan does not support custom code
- Two images you want to compare (before and after)
Good news: you do not need a OneType account. The before-after slider is free - no token, no sign-up.
Step 1: Add the script tag
This loads the OneType Transforms library on every page of your site. You only need to do this once.
- Open your project in the Webflow Designer
- Click the Webflow logo (top left) to go to Site Settings
- Click the Custom Code tab
- In the Footer Code section (before ), paste this:
<script src="https://cdn.transforms.onetype.ai/script/57095981335841558d328d599e6f5322.js"></script>
- Click Save Changes
That is the only setup step. The script loads on every page, but it only activates on elements that have the ot attribute.
Step 2: Add the before-after slider
The before-after slider needs two images inside a div. In Webflow, the easiest way is with an Embed element:
- Press A to open the Add Elements panel
- Search for Embed (also called HTML Embed)
- Drag it onto your canvas where you want the slider
- A code editor opens - paste this HTML:
<div ot="before-after">
<img src="YOUR_BEFORE_IMAGE_URL" alt="Before">
<img src="YOUR_AFTER_IMAGE_URL" alt="After">
</div>
- Replace the image URLs with your actual images
- Click Save & Close
The Embed element shows a placeholder in the Designer - that is normal. Custom code only renders on the published site.
Step 3: Publish and test
Click Publish in the top-right corner. Visit your published site and the before-after slider should be live and draggable.
If you do not see it, double-check that you are on a paid site plan (Basic or higher) and that you published after adding the script tag.
Customization options
Add these attributes to the same div to customize the slider:
- ot-position="30" - start the slider at 30% instead of the middle
- ot-direction="vertical" - slide top to bottom instead of left to right
- ot-label-before="Original" - add a text label on the before side
- ot-label-after="Edited" - add a text label on the after side
- ot-hover="true" - slider follows the mouse instead of requiring a drag
Example with labels and vertical mode:
<div ot="before-after" ot-direction="vertical" ot-label-before="Before" ot-label-after="After">
<img src="before.jpg" alt="Before">
<img src="after.jpg" alt="After">
</div>
Webflow Designer Extension
If you prefer not to write any HTML at all, OneType has a Webflow Designer Extension that lets you apply transforms directly inside the Webflow Designer. Select an element, pick a transform, and it adds the attributes for you.
Troubleshooting
- Slider does not show up - make sure you published the site. Custom code does not render in the Designer preview.
- Script tag not saving - check that you are on a Basic plan or higher. The Starter (free) plan does not support custom code.
- Images are not loading - make sure the image URLs are correct and publicly accessible. Upload them to Webflow Assets if needed.
For more transforms like tilt, magnetic, and typewriter, check out the full collection at transforms.onetype.ai. Back to the main before-after slider guide.