Back to Top

Pinned floating button that appears once the user has scrolled past visibilityThreshold and scrolls to the top on click.

Installation

import { WrBackTop } from 'ngwr/back-top';

@Component({ imports: [WrBackTop] })
export class MyComponent {}

Demo

Scroll down past 400px to reveal the button in the bottom-right corner. The sandbox below provides the scroll runway.

<wr-back-top visibilityThreshold="400" [offset]="80" />
Top of sandbox — scroll the page to push past the 400px threshold.Mid-section — by now the back-to-top button should be pinned in the bottom-right.Bottom of sandbox — click the floating button to scroll back up.

API

NameDescriptionTypeDefault
visibilityThresholdShow the button once window.scrollY exceeds this many pixels.number400
offsetPixel offset subtracted from the scroll target — for sticky headers.number0
ariaLabelAccessible label for the button. Falls back to backTop.label, then 'Back to top'.string | nullnull