DEV Community

Cover image for How to create a dynamic `scrollToTop` button in React! No library necessary! EVER
Chris Hansen
Chris Hansen

Posted on

How to create a dynamic `scrollToTop` button in React! No library necessary! EVER

Hey devs πŸ‘‹

Have you always wanted to know how to get that buttery smooth scroll back to top button!?

Ya don't need another library to achieve this! Get the job done in just a few minutes with some basic logic and javascript!


PREFACE

This is a speedcode tutorial, and I'll assume you have some working knowledge of:

  • HTML, CSS, JS
  • React
  • Good concept of CSS or SASS
  • Not necessary, but I'll be using Styled-components ( CSS in JS library )

Resources

  1. React
  2. React Icons
  3. Styled-Components

Speedcode tutorial ‡️


Conclusion

Thats it for "How to create a dynamic scrollToTop button in React! No library necessary! EVER" I hope you enjoyed the video, and hope you never have to use another scroll button library again! Once you get the hang of the code, you'll be able to add this to your website in just a couple minutes, no doubt about it! #happycoding!


Additional resources you may enjoy!

Top comments (1)

Collapse
 
hyggedev profile image
Chris Hansen

Sweet, thanks for that input! I've been looking into browser performance best practices but I'm still trying to get better at the basics of react! I'll look into this though πŸ’―