svelte-backtotop
Demos:
- None Yet
How to use
-
Install
npm install --save-dev svelte-backtotop
-
Use in a svelte component, for example
_layout.svelte
:<div class="layout"><Navbar /><div class="container mt-4"><slot></slot></div><br class="last-br" />#if processbrowser<BackToTop><button class="btn btn-secondary btn-to-top" type="button"><Icon data=chevronUp /></button></BackToTop>/if</div><script>// or if you're not using any props/events:// import BackToTop from 'svelte-backtotop/src/components/SimpleBackToTop.svelte'</script><style>last-br/* the user needs to be able to scroll back far enough to click buttons *//* otherwise the scroll to top button wiill block other buttons */padding-bottom: 10rem;</style> -
Further Notes:
- this is a port of https://github.com/caiofsouza/vue-backtotop which was for a non-svelte front-end framework