ScrollTop gets displayed after a certain scroll position and used to navigates to the top of the page quickly.
import { ScrollTopModule } from 'primeng/scrolltop';
ScrollTop listens window scroll by default.
Scroll down the page to display the ScrollTo component.
<p-scrollTop />
Setting the target property to parent binds ScrollTop to its parent element that has scrolling content.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vitae et leo duis ut diam. Ultricies mi quis hendrerit dolor magna eget est lorem. Amet consectetur adipiscing elit ut. Nam libero justo laoreet sit amet. Pharetra massa massa ultricies mi quis hendrerit dolor magna. Est ultricies integer quis auctor elit sed vulputate. Consequat ac felis donec et. Tellus orci ac auctor augue mauris. Semper feugiat nibh sed pulvinar proin gravida hendrerit lectus a. Tincidunt arcu non sodales neque sodales. Metus aliquam eleifend mi in nulla posuere sollicitudin aliquam ultrices. Sodales ut etiam sit amet nisl purus. Cursus sit amet dictum sit amet. Tristique senectus et netus et malesuada fames ac turpis egestas. Et tortor consequat id porta nibh venenatis cras sed. Diam maecenas ultricies mi eget mauris. Eget egestas purus viverra accumsan in nisl nisi. Suscipit adipiscing bibendum est ultricies integer. Mattis aliquam faucibus purus in massa tempor nec.
<p-scrollTop
target="parent"
styleClass="custom-scrolltop"
[threshold]="100"
icon="pi pi-arrow-up" />
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
p-scrolltop | Container element. |
p-scrolltop-sticky | Container element when attached to its parent. |
ScrollTop uses a button element with an aria-label that refers to the aria.scrollTop property of the locale API by default, you may use your own aria roles and attributes as any valid attribute is passed to the button element implicitly.
Key | Function |
---|---|
enter | Scrolls to top. |
space | Scrolls to top. |
API defines helper props, events and others for the PrimeNG ScrollTop module.
ScrollTop gets displayed after a certain scroll position and used to navigates to the top of the page quickly.
Defines the input properties of the component.
Defines the templates used by the component.