Vue3 ScrollTop

Vue3 ScrollTop

·

1 min read

Vue3 ScrollTop gets displayed after a certain scroll position and used to navigates to the top of the page quickly. It supports Vue 3 with PrimeVue 3 and Vue 2 with PrimeVue 2.

Setup

Refer to PrimeVue setup documentation for download and installation steps for your environment such as Vue CLI, Vite or browser.

Import

import ScrollTop from 'primevue/scrolltop';

Getting Started

Without any configuration, ScrollTop listens window scroll.

<ScrollTop />

Threshold

When the vertical scroll position reaches a certain value, ScrollTop gets displayed. This value is defined with the threshold property that defaults to 400.

<ScrollTop :threshold="200" />

Target Element

ScrollTop can also be assigned to its parent element by setting target as "parent".

<div style="height: 400px; overflow: auto">
    Content that overflows to container
    <ScrollTop />
</div>

Theming

ScrollTop supports various themes featuring Material, Bootstrap, Fluent as well as your own custom themes via the Designer tool.

Resources

Visit the PrimeVue ScrollTop showcase for demos and documentation.