Minimal Back To Top Button In Pure JavaScript – up-button

Category: Javascript | October 27, 2020
Author: TheSanches
Views Total: 92 views
Official Page: Go to website
Last Update: October 27, 2020
License: MIT


Minimal Back To Top Button In Pure JavaScript – up-button


A minimal yet customizable and smooth scroll to top button component implemented in vanilla JavaScript.

The back to top button displays when the page scrolls down more than 400px and automatically dismisses itself on scroll up.

How to use it:

1. Insert the up-button’s files into the document.

<link rel="stylesheet" href="up_btn.css" />
<script src="up_btn.js"></script>

2. Initialize the library to generate a basic back to top button.


3. Customize the back to top button by passing the following parameters to the up() function.


  // bottom position
  bottom: '20px',

  // right position
  right: '20px',

  // width
  width: '45px',

  // height
  height: '45px',

  // background color
  bg: 'green',

  // custom icon
  src: './chevron-up-solid.svg',

  // distance from the top to show the back to top button
  whenShow: 400,

  // circular button?
  circle: true



  • Update up_btn.js

You Might Be Interested In:

Leave a Reply