Skip to content

BackTop ​

Brief Introduction ​

The BackTop component is used to quickly return to the top of the page. mengyue-components has encapsulated it and performed vitest testing. You can use <MYBackTop></MYBackTop> or <MYBackTop /> to implement a back-to-top component.

Basic Usage ​

visibilityHeight ​

Use the visibilityHeight prop to set the scroll height threshold. The back-to-top button will appear when the page scroll exceeds this value. The default value is 200.

Code Demo
展开代码

Custom Position ​

Use the right and bottom props to customize the component's position on the page.

Code Demo
展开代码

Custom Slot Usage ​

Use slots to fully customize the content and style of the back-to-top button.

Code Demo
展开代码

API Reference ​

Props ​

PropDescriptionTypeOptionsDefault
visibilityHeightScroll height threshold, show button when exceedednumber—200
rightDistance from the right sidenumber | string—40
bottomDistance from the bottomnumber | string—40
targetTarget element for scroll listeningstring—''

Type Definitions ​

typescript
interface BackTopProps {
  visibilityHeight?: number;
  right?: string | number;
  bottom?: string | number;
  target?: string;
}

Released under the MIT License.