# How to develop this product switcher?

**URL:** <https://community.shopify.dev/t/how-to-develop-this-product-switcher/14286>\
**Category:** Online Store and Theme Development\
**Tags:** liquid\
**Created:** [April 27, 2025, 9:07am UTC](https://community.shopify.dev/t/how-to-develop-this-product-switcher/14286 "2025-04-27T09:07:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akash\_Devaraju](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@Akash\_Devaraju](https://community.shopify.dev/u/Akash_Devaraju)\
**Post date:** [April 27, 2025, 9:07am UTC](https://community.shopify.dev/t/how-to-develop-this-product-switcher/14286/1 "2025-04-27T09:07:06Z")

</div>

Hi!

I wanted to understand how to build this product switcher, which allows you to navigate to other products from within a product.

 ![Screenshot 2025-04-27 at 2.35.15 PM](https://global.discourse-cdn.com/shopifycommunity/original/2X/2/268825a14526b331bdf57babdab7c7ff045531e4.jpeg)

Live page here

> **[Classic Root Beer](https://drinkolipop.com/products/classic-root-beer)**
>
> Experience OLIPOP's Prebiotic Root Beer! A botanically inspired blend with a classic bite and sweet birch creaminess. Perfect with your beloved ice cream.

also present here

> **[Wildwonder Sparkling Drink Variety Pack | wildwonder](https://drinkwildwonder.com/products/variety-pack)**
>
> Experience 5 flavors in our variety pack of prebiotic, probiotic and herbal sparkling drinks. Order yours today!

Is this a readily available plugin? or a theme? if not how do I make this?

---

<div class="post-metadata">

**Author:** ![kinngh](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/kinngh/32/55_2.png) [@kinngh](https://community.shopify.dev/u/kinngh)\
**Post date:** [April 27, 2025, 3:04pm UTC](https://community.shopify.dev/t/how-to-develop-this-product-switcher/14286/2 "2025-04-27T15:04:00Z")

</div>

They have a `style` on the body with the CSS color. This is a plain implementation on how you’d do it:

`index.html`

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Page 1</title>
  <style>
    html { transition: background-color 0.5s ease; }
    body { margin:0; font-family:sans-serif; display:flex; align-items:center; justify-content:center; height:100vh; }
    a { text-decoration:none; padding:8px 12px; border:1px solid; border-radius:4px; }
  </style>
</head>
<body>
  <main id="main" data-bg="#ffffff">
    <h1>Page 1</h1>
    <a href="/page2.html" class="nav-link">Go to Page 2</a>
  </main>

  <script type="module">
    const main = document.getElementById('main');

    async function loadPage(url, addToHistory = true) {
      const res = await fetch(url);
      const txt = await res.text();
      const doc = new DOMParser().parseFromString(txt, 'text/html');
      const nxt = doc.getElementById('main');
      const bg = nxt.dataset.bg;
      // trigger background‐color transition
      document.documentElement.style.backgroundColor = bg;
      // swap content
      main.innerHTML = nxt.innerHTML;
      if (addToHistory) history.pushState(null, '', url);
    }

    // intercept clicks
    document.body.addEventListener('click', e => {
      const a = e.target.closest('a.nav-link');
      if (a && a.origin === location.origin) {
        e.preventDefault();
        loadPage(a.href);
      }
    });

    // back/forward
    window.addEventListener('popstate', () => {
      loadPage(location.pathname, false);
    });

    // set initial bg
    document.documentElement.style.backgroundColor = main.dataset.bg;
  </script>
</body>
</html>

```

`page2.html`

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Page 2</title>
  <style>
    html { transition: background-color 0.5s ease; }
    body { margin:0; font-family:sans-serif; display:flex; align-items:center; justify-content:center; height:100vh; }
    a { text-decoration:none; padding:8px 12px; border:1px solid; border-radius:4px; }
  </style>
</head>
<body>
  <main id="main" data-bg="#8ecae6">
    <h1>Page 2</h1>
    <a href="/index.html" class="nav-link">Back to Page 1</a>
  </main>

  <script type="module">
    // same script as above…
    const main = document.getElementById('main');

    async function loadPage(url, addToHistory = true) {
      const res = await fetch(url);
      const txt = await res.text();
      const doc = new DOMParser().parseFromString(txt, 'text/html');
      const nxt = doc.getElementById('main');
      const bg = nxt.dataset.bg;
      document.documentElement.style.backgroundColor = bg;
      main.innerHTML = nxt.innerHTML;
      if (addToHistory) history.pushState(null, '', url);
    }

    document.body.addEventListener('click', e => {
      const a = e.target.closest('a.nav-link');
      if (a && a.origin === location.origin) {
        e.preventDefault();
        loadPage(a.href);
      }
    });

    window.addEventListener('popstate', () => {
      loadPage(location.pathname, false);
    });

    document.documentElement.style.backgroundColor = main.dataset.bg;
  </script>
</body>
</html>

```

---

<div class="post-metadata">

**Author:** ![Shadab\_dev\_ali](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/shadab_dev_ali/32/4740_2.png) [@Shadab\_dev\_ali](https://community.shopify.dev/u/Shadab_dev_ali)\
**Post date:** [May 2, 2025, 2:10am UTC](https://community.shopify.dev/t/how-to-develop-this-product-switcher/14286/3 "2025-05-02T02:10:16Z")

</div>

These basically are different variants in the context of flavours for a single product. I am pretty sure you get that.

So these are in my understanding image swatches customised pretty neatly.

---

<div class="post-metadata">

**Author:** ![Liam-Shopify](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/liam-shopify/32/6_2.png) [@Liam-Shopify](https://community.shopify.dev/u/Liam-Shopify)\
**Post date:** [May 5, 2025, 6:33am UTC](https://community.shopify.dev/t/how-to-develop-this-product-switcher/14286/4 "2025-05-05T06:33:14Z")

</div>

Hi Akash,

Are you still having an issue with this, or can I mark this as solved?
