Backtop
A button that scrolls back to the top when clicked. Appears after scrolling past a threshold. Supports progress ring, sizes, shapes, and more.
Basic
Scroll down inside the box to see the backtop button appear.
<VxBacktop />Progress Ring
Show a circular progress indicator around the button with show-progress.
<VxBacktop show-progress />Scroll Percentage
Show the scroll percentage inside the button with show-percent. Combines well with show-progress.
<VxBacktop show-progress show-percent />Sizes
Three sizes: small (32px), default (40px), large (48px).
<VxBacktop size="small" />
<VxBacktop size="default" />
<VxBacktop size="large" />Shape
Choose between circle (default) and square (rounded square).
<VxBacktop shape="circle" />
<VxBacktop shape="square" />Tooltip
Add a native tooltip with the tooltip prop.
<VxBacktop tooltip="Back to top" />Scroll To Element
Scroll to a specific element instead of the top using scroll-to.
<VxBacktop scroll-to="#my-section" />Custom Content
Use the default slot for custom content. The slot exposes percent.
<VxBacktop show-progress size="large">
<template #default="{ percent }">
<span>{{ percent }}%</span>
</template>
</VxBacktop>Full Custom Button
Use the #button slot to replace the entire button. It receives { percent, visible, scroll, style } — call scroll($event) to trigger the scroll, apply style for positioning.
<VxBacktop>
<template #button="{ percent, scroll, style }">
<div :style="style" @click="scroll">
Back to top · {{ percent }}%
</div>
</template>
</VxBacktop>Disabled
<VxBacktop disabled />Auto Hide
Hide after idle time (ms). The button reappears when you scroll again.
<!-- Hide after 3 seconds of no scrolling -->
<VxBacktop :auto-hide="3000" />API
VxBacktop Props
| Prop | Type | Default | Description |
|---|---|---|---|
target | string | HTMLElement | window | Scroll container |
visibility-height | number | 200 | Scroll threshold to show (px) |
right | number | 40 | Right offset (px) |
bottom | number | 40 | Bottom offset (px) |
smooth | boolean | true | Smooth scroll animation |
size | 'small' | 'default' | 'large' | 'default' | Button size |
shape | 'circle' | 'square' | 'circle' | Button shape |
show-progress | boolean | false | Show circular scroll progress ring |
show-percent | boolean | false | Show scroll percentage text |
scroll-to | string | — | CSS selector to scroll to instead of top |
tooltip | string | — | Native tooltip text |
disabled | boolean | false | Disable the button |
auto-hide | number | 0 | Auto-hide after idle (ms), 0 = off |
root-class | string | string[] | object | — | Class on root element |
Events
| Event | Payload | Description |
|---|---|---|
click | MouseEvent | Button clicked |
Slots
| Slot | Props | Description |
|---|---|---|
default | { percent: number } | Custom inner content (replaces icon) |
button | { percent: number, visible: boolean, scroll: Function, style: object } | Replace the entire button. Use style for positioning, call scroll($event) to trigger scroll. |
Exposed
| Name | Type | Description |
|---|---|---|
visible | Ref<boolean> | Whether the button is visible |
scrollPercent | Ref<number> | Current scroll percentage (0–100) |