How to add a slider to the top

Topic summary

A user wants to add a “scroll to top” button in the bottom-right corner of their Shopify store, functional on both mobile and desktop.

Solution provided:

  • Add HTML code for the button before the </body> tag in theme.liquid
  • Style the button using CSS in the theme’s stylesheet
  • Implement JavaScript to show/hide the button based on scroll position and enable smooth scrolling
  • Test on both desktop and mobile devices

Current status:
The initial implementation is working successfully. The user now requests design adjustments:

  • Make the arrow icon smaller
  • Add a gray circular background
  • Increase spacing from the bottom and right edges

The discussion remains open with the follow-up customization request pending response.

Summarized with AI on November 2. AI used: claude-sonnet-4-5-20250929.

Hey guys, how can I add that button to the bottom-right corner so that when I click it, it scrolls me all the way to the top?

I want this for both mobile and desktop.

Here’s the store where it is: https://tomnoske.store/
(Just scroll down so you can see it)

I would like to add the same thing to my store, and make sure it works on both desktop and mobile.

Here’s my store: https://1049xn-ya.myshopify.com/

Thanks a lot,
Tim

Hi @CreatorTim

Hey there! Adding a “Scroll to Top” button is a great idea—it’s user-friendly and looks clean. Here’s how you can do it, step by step, so it works on both mobile and desktop. Don’t worry; it’s not as complicated as it seems!

1-Add the HTML for the Button

You’ll need to include the HTML code for the button in your Shopify theme. Follow these steps:

  1. Go to your Shopify Admin.
  2. Navigate to Online Store > Themes and click Customize.
  3. In the top right corner, click Edit code.
  4. Find the theme.liquid file in the Layout section.
  5. Add the following code right before the tag:

html

Copy code

↑ Top

2-Add CSS to Style the Button

Now, you’ll make the button look good and ensure it’s positioned properly.

  1. In the Edit Code section, locate your theme’s CSS file (usually theme.css or styles.css).
  2. Add this code:

css

Copy code

#scrollToTop {

display: none;

position: fixed;

bottom: 20px;

right: 20px;

z-index: 1000;

}

#scrollToTop button {

background-color: #000;

color: #fff;

border: none;

padding: 10px 15px;

border-radius: 5px;

cursor: pointer;

font-size: 16px;

}

3-Add JavaScript for the Scroll Functionality

Finally, let’s make the button work. Add this script to your theme.liquid file, just above the tag:

javascript

Copy code

4-Test It Out- Visit your store on both desktop and mobile devices.

  • Scroll down and see if the button appears.
  • Click the button and ensure it smoothly scrolls you back to the top.

A Few Notes- The button’s styling can be customized—colors, size, position—just tweak the CSS code above.

  • If you’re using an app or third-party theme that modifies your theme code, double-check it doesn’t conflict with your changes.

That’s it! You now have a “Scroll to Top” button that works on both desktop and mobile. If something doesn’t work or you need help with customization, let me know—I’m happy to assist.

Best regards,
Daisy.

1 Like

Hey, thanks a lot, it works!!

But how can I adjust the design so that the arrow inside is smaller, it’s in a gray circle, and it has more spacing? Like, move it further away from the bottom and the right.

Thank you so much!
Tim