Sliders & carousels

Before-After Slider for Shopify - Step by Step

Stefan Pakic2 min read

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

Shopify does not have a built-in before-after slider. Most apps that add one are paid subscriptions. You can add one for free with a single line in your theme code and a Custom Liquid section.

The slider above is a live demo. Here is how to add it to your Shopify store.

What you need

  • A Shopify store on a Basic plan or higher - the Starter plan does not have an online store
  • Two images you want to compare

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

Step 1: Add the script tag to theme.liquid

This is a one-time setup. The script loads on every page of your store.

  1. Go to Online Store > Themes
  2. On your active theme, click the three dots (...) > Edit code
  3. In the left sidebar, open Layout > theme.liquid
  4. Find (use Ctrl+F or Cmd+F)
  5. On the line directly above it, paste:
<script src="https://cdn.transforms.onetype.ai/script/57095981335841558d328d599e6f5322.js"></script>
  1. Click Save

Tip: always duplicate your theme before editing code (Theme actions > Duplicate). That way you have a backup if anything goes wrong.

Step 2: Add the slider to any page

You do not need to touch the code editor again. Use the visual theme editor:

  1. Go to Online Store > Themes > Customize
  2. Use the page dropdown at the top to navigate to the page you want
  3. Click Add section
  4. Select Custom Liquid
  5. In the Liquid code field, paste:
<div ot="before-after">
  <img src="YOUR_BEFORE_IMAGE_URL" alt="Before">
  <img src="YOUR_AFTER_IMAGE_URL" alt="After">
</div>
  1. Drag the section to position it where you want
  2. Click Save

The slider should appear immediately in the theme preview. Custom Liquid sections survive theme updates, so you will not lose your slider when you update your theme.

Customization

Add attributes to change the slider behavior:

  • 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

Good to know

  • The script tag in theme.liquid may need to be re-added after theme updates. Custom Liquid sections added through the editor are safe.
  • The slider does not work on checkout pages - Shopify locks those down on all plans.
  • Works on all modern Shopify themes including the free Dawn theme.

Get started

The before-after slider is free at transforms.onetype.ai. For all customization options, 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