BackTop Component

BackTop component provides a convenient way for users to quickly return to the top of the page, especially suitable for long content pages.
Basic Usage
Basic back to top button that appears when the page scrolls beyond a specified height.
This is line 1 of example text. Please scroll down to see the back to top button effect.
This is line 2 of example text. Please scroll down to see the back to top button effect.
This is line 3 of example text. Please scroll down to see the back to top button effect.
This is line 4 of example text. Please scroll down to see the back to top button effect.
This is line 5 of example text. Please scroll down to see the back to top button effect.
This is line 6 of example text. Please scroll down to see the back to top button effect.
This is line 7 of example text. Please scroll down to see the back to top button effect.
This is line 8 of example text. Please scroll down to see the back to top button effect.
This is line 9 of example text. Please scroll down to see the back to top button effect.
This is line 10 of example text. Please scroll down to see the back to top button effect.
This is line 11 of example text. Please scroll down to see the back to top button effect.
This is line 12 of example text. Please scroll down to see the back to top button effect.
This is line 13 of example text. Please scroll down to see the back to top button effect.
This is line 14 of example text. Please scroll down to see the back to top button effect.
This is line 15 of example text. Please scroll down to see the back to top button effect.
This is line 16 of example text. Please scroll down to see the back to top button effect.
This is line 17 of example text. Please scroll down to see the back to top button effect.
This is line 18 of example text. Please scroll down to see the back to top button effect.
This is line 19 of example text. Please scroll down to see the back to top button effect.
This is line 20 of example text. Please scroll down to see the back to top button effect.
This is line 21 of example text. Please scroll down to see the back to top button effect.
This is line 22 of example text. Please scroll down to see the back to top button effect.
This is line 23 of example text. Please scroll down to see the back to top button effect.
This is line 24 of example text. Please scroll down to see the back to top button effect.
This is line 25 of example text. Please scroll down to see the back to top button effect.
This is line 26 of example text. Please scroll down to see the back to top button effect.
This is line 27 of example text. Please scroll down to see the back to top button effect.
This is line 28 of example text. Please scroll down to see the back to top button effect.
This is line 29 of example text. Please scroll down to see the back to top button effect.
This is line 30 of example text. Please scroll down to see the back to top button effect.
Custom Icon
You can customize the icon of the back to top button by setting the icon attribute.
Plain Style
Setting the plain attribute enables a plain style back to top button with background color and border.
This is line 1 of example text. Please scroll down to see the plain style back to top button.
This is line 2 of example text. Please scroll down to see the plain style back to top button.
This is line 3 of example text. Please scroll down to see the plain style back to top button.
This is line 4 of example text. Please scroll down to see the plain style back to top button.
This is line 5 of example text. Please scroll down to see the plain style back to top button.
This is line 6 of example text. Please scroll down to see the plain style back to top button.
This is line 7 of example text. Please scroll down to see the plain style back to top button.
This is line 8 of example text. Please scroll down to see the plain style back to top button.
This is line 9 of example text. Please scroll down to see the plain style back to top button.
This is line 10 of example text. Please scroll down to see the plain style back to top button.
This is line 11 of example text. Please scroll down to see the plain style back to top button.
This is line 12 of example text. Please scroll down to see the plain style back to top button.
This is line 13 of example text. Please scroll down to see the plain style back to top button.
This is line 14 of example text. Please scroll down to see the plain style back to top button.
This is line 15 of example text. Please scroll down to see the plain style back to top button.
This is line 16 of example text. Please scroll down to see the plain style back to top button.
This is line 17 of example text. Please scroll down to see the plain style back to top button.
This is line 18 of example text. Please scroll down to see the plain style back to top button.
This is line 19 of example text. Please scroll down to see the plain style back to top button.
This is line 20 of example text. Please scroll down to see the plain style back to top button.
This is line 21 of example text. Please scroll down to see the plain style back to top button.
This is line 22 of example text. Please scroll down to see the plain style back to top button.
This is line 23 of example text. Please scroll down to see the plain style back to top button.
This is line 24 of example text. Please scroll down to see the plain style back to top button.
This is line 25 of example text. Please scroll down to see the plain style back to top button.
This is line 26 of example text. Please scroll down to see the plain style back to top button.
This is line 27 of example text. Please scroll down to see the plain style back to top button.
This is line 28 of example text. Please scroll down to see the plain style back to top button.
This is line 29 of example text. Please scroll down to see the plain style back to top button.
This is line 30 of example text. Please scroll down to see the plain style back to top button.
Custom Position
You can customize the position of the back to top button by setting the bottom and right attributes.
This is line 1 of example text. Please scroll down to see back to top buttons at different positions.
This is line 2 of example text. Please scroll down to see back to top buttons at different positions.
This is line 3 of example text. Please scroll down to see back to top buttons at different positions.
This is line 4 of example text. Please scroll down to see back to top buttons at different positions.
This is line 5 of example text. Please scroll down to see back to top buttons at different positions.
This is line 6 of example text. Please scroll down to see back to top buttons at different positions.
This is line 7 of example text. Please scroll down to see back to top buttons at different positions.
This is line 8 of example text. Please scroll down to see back to top buttons at different positions.
This is line 9 of example text. Please scroll down to see back to top buttons at different positions.
This is line 10 of example text. Please scroll down to see back to top buttons at different positions.
This is line 11 of example text. Please scroll down to see back to top buttons at different positions.
This is line 12 of example text. Please scroll down to see back to top buttons at different positions.
This is line 13 of example text. Please scroll down to see back to top buttons at different positions.
This is line 14 of example text. Please scroll down to see back to top buttons at different positions.
This is line 15 of example text. Please scroll down to see back to top buttons at different positions.
This is line 16 of example text. Please scroll down to see back to top buttons at different positions.
This is line 17 of example text. Please scroll down to see back to top buttons at different positions.
This is line 18 of example text. Please scroll down to see back to top buttons at different positions.
This is line 19 of example text. Please scroll down to see back to top buttons at different positions.
This is line 20 of example text. Please scroll down to see back to top buttons at different positions.
This is line 21 of example text. Please scroll down to see back to top buttons at different positions.
This is line 22 of example text. Please scroll down to see back to top buttons at different positions.
This is line 23 of example text. Please scroll down to see back to top buttons at different positions.
This is line 24 of example text. Please scroll down to see back to top buttons at different positions.
This is line 25 of example text. Please scroll down to see back to top buttons at different positions.
This is line 26 of example text. Please scroll down to see back to top buttons at different positions.
This is line 27 of example text. Please scroll down to see back to top buttons at different positions.
This is line 28 of example text. Please scroll down to see back to top buttons at different positions.
This is line 29 of example text. Please scroll down to see back to top buttons at different positions.
This is line 30 of example text. Please scroll down to see back to top buttons at different positions.
Custom Trigger Height
You can customize the scroll height that triggers the back to top button display by setting the visibilityHeight attribute.
This is line 1 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 2 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 3 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 4 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 5 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 6 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 7 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 8 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 9 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 10 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 11 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 12 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 13 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 14 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 15 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 16 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 17 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 18 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 19 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 20 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 21 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 22 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 23 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 24 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 25 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 26 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 27 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 28 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 29 of example text. Please scroll down to see back to top buttons with different trigger heights.
This is line 30 of example text. Please scroll down to see back to top buttons with different trigger heights.
Specify Scroll Container
You can specify the container element that triggers scrolling by setting the target attribute, which can be a CSS selector string or HTML element.
This is line 1 of example text in container 1.
This is line 2 of example text in container 1.
This is line 3 of example text in container 1.
This is line 4 of example text in container 1.
This is line 5 of example text in container 1.
This is line 6 of example text in container 1.
This is line 7 of example text in container 1.
This is line 8 of example text in container 1.
This is line 9 of example text in container 1.
This is line 10 of example text in container 1.
This is line 11 of example text in container 1.
This is line 12 of example text in container 1.
This is line 13 of example text in container 1.
This is line 14 of example text in container 1.
This is line 15 of example text in container 1.
This is line 16 of example text in container 1.
This is line 17 of example text in container 1.
This is line 18 of example text in container 1.
This is line 19 of example text in container 1.
This is line 20 of example text in container 1.
This is line 1 of example text in container 2.
This is line 2 of example text in container 2.
This is line 3 of example text in container 2.
This is line 4 of example text in container 2.
This is line 5 of example text in container 2.
This is line 6 of example text in container 2.
This is line 7 of example text in container 2.
This is line 8 of example text in container 2.
This is line 9 of example text in container 2.
This is line 10 of example text in container 2.
This is line 11 of example text in container 2.
This is line 12 of example text in container 2.
This is line 13 of example text in container 2.
This is line 14 of example text in container 2.
This is line 15 of example text in container 2.
This is line 16 of example text in container 2.
This is line 17 of example text in container 2.
This is line 18 of example text in container 2.
This is line 19 of example text in container 2.
This is line 20 of example text in container 2.
Custom Content
You can customize the content of the back to top button through the default slot, completely controlling its appearance.
This is line 1 of example text. Please scroll down to see back to top buttons with custom content.
This is line 2 of example text. Please scroll down to see back to top buttons with custom content.
This is line 3 of example text. Please scroll down to see back to top buttons with custom content.
This is line 4 of example text. Please scroll down to see back to top buttons with custom content.
This is line 5 of example text. Please scroll down to see back to top buttons with custom content.
This is line 6 of example text. Please scroll down to see back to top buttons with custom content.
This is line 7 of example text. Please scroll down to see back to top buttons with custom content.
This is line 8 of example text. Please scroll down to see back to top buttons with custom content.
This is line 9 of example text. Please scroll down to see back to top buttons with custom content.
This is line 10 of example text. Please scroll down to see back to top buttons with custom content.
This is line 11 of example text. Please scroll down to see back to top buttons with custom content.
This is line 12 of example text. Please scroll down to see back to top buttons with custom content.
This is line 13 of example text. Please scroll down to see back to top buttons with custom content.
This is line 14 of example text. Please scroll down to see back to top buttons with custom content.
This is line 15 of example text. Please scroll down to see back to top buttons with custom content.
This is line 16 of example text. Please scroll down to see back to top buttons with custom content.
This is line 17 of example text. Please scroll down to see back to top buttons with custom content.
This is line 18 of example text. Please scroll down to see back to top buttons with custom content.
This is line 19 of example text. Please scroll down to see back to top buttons with custom content.
This is line 20 of example text. Please scroll down to see back to top buttons with custom content.
This is line 21 of example text. Please scroll down to see back to top buttons with custom content.
This is line 22 of example text. Please scroll down to see back to top buttons with custom content.
This is line 23 of example text. Please scroll down to see back to top buttons with custom content.
This is line 24 of example text. Please scroll down to see back to top buttons with custom content.
This is line 25 of example text. Please scroll down to see back to top buttons with custom content.
This is line 26 of example text. Please scroll down to see back to top buttons with custom content.
This is line 27 of example text. Please scroll down to see back to top buttons with custom content.
This is line 28 of example text. Please scroll down to see back to top buttons with custom content.
This is line 29 of example text. Please scroll down to see back to top buttons with custom content.
This is line 30 of example text. Please scroll down to see back to top buttons with custom content.
BackTop Component API
Attributes
| Attribute | Description | Type | Accepted Values | Default |
|---|---|---|---|---|
| target | Target element that triggers scrolling | HTMLElement/string | — | — |
| icon | Icon type | string | — | caret-up |
| icon-size | Icon size | number | — | 32 |
| bottom | Distance from bottom | string | — | 32px |
| right | Distance from right | string | — | 32px |
| visibility-height | Scroll height that triggers display | number | — | 200 |
| plain | Whether to use plain style | boolean | — | false |
Events
| Event Name | Description | Callback Parameters |
|---|---|---|
| click | Triggered when button is clicked | — |
Slots
| Slot Name | Description |
|---|---|
| default | Custom button content |
Style Variables
BackTop component uses the following style variables, which can be customized through SCSS variables:
| Variable Name | Description |
|---|---|
| $theme-color-primary | Primary theme color |
| $color-white | White color |
| $bg-color-default | Default background color |
| $z-index-up | Upper layer z-index |
Tune UI