Add back-to-top button easily with Bricks Builder without using an extra plugin

Estimated reading time: 3 minutes

Credits to Grant Ambrose

Certainly! The Back Button is a crucial element in web design for several reasons:

  1. User Experience Simplification: The Back Button allows users to effortlessly return to a previous screen or webpage without having to search for it again or manually input the URL. This simplicity enhances the overall user experience and saves valuable time.
  2. Maintaining Flow: When users navigate through a website, they follow a logical flow. The Back Button ensures that users can easily retrace their steps, maintaining the continuity of their interaction. Without it, users might feel disoriented or frustrated.
  3. Frequent Usage: The Back Button is one of the most frequently used navigation elements. Studies have shown that users rely on it extensively. For instance, Mozilla’s research found that 93.1% of participants used the Back Button at least once, clicking it an average of 66.2 times over five days. This usage far surpasses other navigation buttons like Reload, Home, Forward, and Stop

In summary, the Back Button is like the brake pedal in a car: users expect it to work consistently. Altering its behavior can lead to confusion, frustration, and even abandonment. Therefore, including a functional Back Button in your website design is essential for a positive user experience.🚀

Let’s begin constructing our back-to-top button using Bricks Builder

Currently, Bricks Builder does not have a built-in element specifically for a back-to-top button, although there are additional Bricks plugins available that can provide this functionality. However, what if we prefer not to add extra plugins solely for this purpose?

In this tutorial, we’ll explore how to achieve this without any additional hassle.

To begin, we need to determine whether we want to add our button to the Header or Footer template. Both options are valid, but it’s essential to select the one that appears most frequently on your site. Keep in mind that if you choose the Header and it’s set to sticky functionality, it may lead to some issues, so in most cases, adding it to the Footer is the better option. This ensures that the back-to-top button will function smoothly without any complications.


After you’ve decided which template is best suited for your needs

Go to Bricks > Templates > Choose your template and Edit with Bricks.

In my case, it going to be the Footer Template.


Add a button element and style it according to your preferences

(Ensure that you set it to a fixed position.)

Next, we’ll link our button to an anchor that scrolls us to the top of the page. Usually, we use the Header ID, because the Header always remains at the top of our page, which in our case is “#brx-header“. This ensures a seamless scrolling experience to the top of the webpage when the back-to-top button is clicked.

Do you have a sticky header?

However, there’s a catch. If your Header has sticky functionality, you’ll need to add an extra element on top of your Header so that your back-to-top button can be linked to it. To achieve this, you can either utilize a child theme or, if you have a code snippet plugin, you can add the following code snippet to your functions:

add_action('bricks_before_header', 'c_do_before_header_backtoptop');
function c_do_before_header_backtoptop(){
	echo '<div id="backToTop"></div>';
}
PHP

the following code will create the extra <div id=”backToTop”></div> on top of our Header tag

It’s crucial to ensure that the ID used in the anchor link matches the ID added to the back-to-top button. This alignment ensures that clicking the button will smoothly scroll the page to the specified section, enhancing user experience.

That’s it, you just create a back-top-top button using Bricks Builder!!!

Leave your comment