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 setting position: relative on a parent element, and position: absolute on the BackToTop, we can position the button within the parent.
ReferenceError: React is not definedBy default, the button will appear when the container's scrollTop is greater than 400 pixels. To make it always visible, set the alwaysVisible prop.
ReferenceError: React is not definedProps
| 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';