React ScrollTop gets displayed after a certain scroll position and used to navigates to the top of the page quickly.
Setup
Refer to PrimeReact setup documentation for download and installation steps for your environment.
Import
import { ScrollTop } from 'primereact/scrolltop';
Getting Started
Without any configuration, ScrollTop listens window scroll.
<ScrollTop />
Threshold
When the vertical scroll position reaches a certain value, ScrollTop gets displayed. This value is defined with the threshold property that defaults to 400.
<ScrollTop threshold={200} />
Target Element
ScrollTop can also be assigned to its parent element by setting target as "parent".
<div style={{height: '400px', overflow: 'auto'}}>
Content that overflows to container
<ScrollTop />
</div>
Theming
ScrollTop supports various themes featuring Material, Bootstrap, Fluent as well as your own custom themes via the Designer tool.
Resources
Visit the PrimeReact ScrollTop showcase for demos and documentation.