# Scroll Revealing "Back to the Top" Button

**URL:** <https://forum.wixstudio.com/t/scroll-revealing-back-to-the-top-button/50329>\
**Category:** Ask the community\
**Created:** [March 24, 2021, 9:29pm UTC](https://forum.wixstudio.com/t/scroll-revealing-back-to-the-top-button/50329 "2021-03-24T21:29:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bevolution110](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@bevolution110](https://forum.wixstudio.com/u/bevolution110)\
**Post date:** [March 24, 2021, 9:29pm UTC](https://forum.wixstudio.com/t/scroll-revealing-back-to-the-top-button/50329/1 "2021-03-24T21:29:19Z")

</div>

Is there currently a way to create a “back to the top” button that reveals when scrolling down and disappears at some point of the page when scrolling up?

---

<div class="post-metadata">

**Author:** ![sebi-vidret](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/sebi-vidret/32/740_2.png) [@sebi-vidret](https://forum.wixstudio.com/u/sebi-vidret)\
**Post date:** [March 25, 2021, 11:56am UTC](https://forum.wixstudio.com/t/scroll-revealing-back-to-the-top-button/50329/2 "2021-03-25T11:56:30Z")

</div>

Hi,

Great question!

You can use Velo to trigger an element to show/hide based on the scroll position.

Here is an example code below:

$w (“#myElement”). onViewportEnter ( ( event ) =\> {  
$w(“#backToTop”).show();  
});

---

<div class="post-metadata">

**Author:** ![bevolution110](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@bevolution110](https://forum.wixstudio.com/u/bevolution110)\
**Post date:** [March 26, 2021, 12:06pm UTC](https://forum.wixstudio.com/t/scroll-revealing-back-to-the-top-button/50329/3 "2021-03-26T12:06:00Z")

</div>

thank you

---

<div class="post-metadata">

**Author:** ![joshuasevans5](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/joshuasevans5/32/31820_2.png) [@joshuasevans5](https://forum.wixstudio.com/u/joshuasevans5)\
**Post date:** [January 20, 2022, 2:13pm UTC](https://forum.wixstudio.com/t/scroll-revealing-back-to-the-top-button/50329/4 "2022-01-20T14:13:22Z")

</div>

Hi, how can achieve this without Velo? As i do not have any coding knowledge.

---

<div class="post-metadata">

**Author:** ![user777](https://avatars.discourse-cdn.com/v4/letter/u/9dc877/32.png) [@user777](https://forum.wixstudio.com/u/user777)\
**Post date:** [November 4, 2023, 12:17pm UTC](https://forum.wixstudio.com/t/scroll-revealing-back-to-the-top-button/50329/5 "2023-11-04T12:17:15Z")

</div>

Maybe there is a better way to do it but, here is how i made it work :  
1/ create your back to top button : add element \> choose your button \> fix position \> allow on all pages

2/ create a rectangle box : add element \> choose a box \> put the box where your back to top button go (for example, for me it’s on the right of the page) \> adjust opacity to make the box invisible \> allow on all pages

3/ adjust the box from where you want your back to top button to start showing up all the way down to your page footer

4/ go to dev mod and turn it on \> go to global page code (masterPage.js)\> select the invisible box \> on the coding interface, show “properties and events” \> select OnViewportEnter() and add then select OnViewportLeave() and add

this will add on your global code page these events

5/ under OnViewportEnter() add $w(“#yourbacktotopid”).show()  
under OnViewportLeave() add $w(“#yourbacktotopid”).hide()

Ultimately, it would be something like this (my box id is box10 and my back to top button id is vectorimage4) :

// this hide the button when you load the page  
$w(“#vectorImage4”).hide()

// this show the button when scroll on the page  
export function box10\_viewportEnter(event) {  
$w(“#vectorImage4”).show()  
}

// this hide the button where the box is not  
export function box10\_viewportLeave(event) {  
$w(“#vectorImage4”).hide()  
}
