Back to top
You can use this component to scroll to the top of a document (or another scrollable element).
By default the button will be fixed to the bottom right hand corner of the page. See below for an example of how to override the positioning.
To apply the BackToTop
component to a specific element, use the scrollableId
prop. To use the BackToTop
component to scroll the entire page, do not set the scrollableId
prop.
By default, the button will appear when the container's scrollTop
is greater than 400 pixels. To make it always visible, set the alwaysVisible
prop.
Props
Property | Required | Type | Default | Description |
---|---|---|---|---|
alwaysVisible | no | Boolean | false | If alwaysVisible is not set, the component will only appear after the window has been scrolled. |
scrollableId | no | String | If scrollableId is set, the component will update this element's scrollTop property. Otherwise, document.body will be scrolled. |
Imports
Import React components (including CSS):
import {BackToTop} from 'pivotal-ui/react/back-to-top';
Import CSS only:
import 'pivotal-ui/css/back-to-top';