Sliders & carousels

Before-After Slider for Framer - Step by Step

Stefan Pakic2 min read

A before-after image slider with a draggable handle comparing two photos

Framer does not have a native before-after slider component. You can add one in about two minutes with Custom Code and an Embed component. No React code needed.

The slider above is a live demo. Here is how to get that on your Framer site.

What you need

  • A Framer site on a Basic plan or higher - the free plan does not support Custom Code in Site Settings
  • Two images you want to compare

The before-after slider is free. No OneType account or sign-up needed.

Step 1: Add the script tag

  1. In the Framer editor, click the gear icon (Settings) in the top-right corner
  2. Go to the General tab
  3. Scroll to the Custom Code section at the bottom
  4. Click Show Advanced to see all placement options
  5. In the End of tag field, paste:
<script src="https://cdn.transforms.onetype.ai/script/57095981335841558d328d599e6f5322.js"></script>
  1. Click Save

The script now loads on every page of your site.

Step 2: Add the slider with an Embed component

  1. Open the page where you want the slider
  2. Open the Insert menu (or press /)
  3. Search for Embed
  4. Drag the Embed component onto the canvas
  5. In the component settings, switch to the HTML tab
  6. Paste this:
<div ot="before-after">
  <img src="YOUR_BEFORE_IMAGE_URL" alt="Before">
  <img src="YOUR_AFTER_IMAGE_URL" alt="After">
</div>
  1. Replace the image URLs with your actual images
  2. Resize the Embed component on the canvas to fit your layout

Step 3: Publish

The slider will not render in the Framer editor - that is normal. Publish your site or use the Preview URL to see the slider live and interactive.

Customization

Add these attributes to the div to change the slider:

  • ot-direction="vertical" - slide top to bottom
  • ot-label-before="Original" and ot-label-after="Edited" - text labels
  • ot-position="30" - start at 30% instead of center
  • ot-hover="true" - slider follows the mouse

Why not a Code Component?

You could build this as a Framer Code Component with React, but it is unnecessary. The Embed approach is simpler - paste the HTML and you are done. No React, no TypeScript, no property controls to set up.

If you plan to reuse the same slider on many pages, a Code Component with property controls might save time. But for one or two sliders, the Embed is the way to go.

Get started

The before-after slider is free at transforms.onetype.ai. For all customization options and use cases, check the main before-after slider guide.

More posts

All

Build it today. Pay when it goes live.

Every feature is unmetered while you build.

Start building