ScrollTop
A button back to the top of a long page or a scrolling element, shown past a threshold.
Import
import { ScrollTop } from '@vitral/vue';In an element
Line 1: scroll down and the button appears at the bottom of this box.
Line 2: scroll down and the button appears at the bottom of this box.
Line 3: scroll down and the button appears at the bottom of this box.
Line 4: scroll down and the button appears at the bottom of this box.
Line 5: scroll down and the button appears at the bottom of this box.
Line 6: scroll down and the button appears at the bottom of this box.
Line 7: scroll down and the button appears at the bottom of this box.
Line 8: scroll down and the button appears at the bottom of this box.
Line 9: scroll down and the button appears at the bottom of this box.
Line 10: scroll down and the button appears at the bottom of this box.
Line 11: scroll down and the button appears at the bottom of this box.
Line 12: scroll down and the button appears at the bottom of this box.
Line 13: scroll down and the button appears at the bottom of this box.
Line 14: scroll down and the button appears at the bottom of this box.
Line 15: scroll down and the button appears at the bottom of this box.
Line 16: scroll down and the button appears at the bottom of this box.
Line 17: scroll down and the button appears at the bottom of this box.
Line 18: scroll down and the button appears at the bottom of this box.
Line 19: scroll down and the button appears at the bottom of this box.
Line 20: scroll down and the button appears at the bottom of this box.
API
Read from packages/vue/src/components/ScrollTop/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| target | 'window' | 'parent' | What it scrolls: the page (the default) or the element it is placed in. |
| threshold | number | How far down, in pixels, before it appears. Defaults to 400. |
| icon | IconProp | Defaults to an up arrow. |
| behavior | 'smooth' | 'auto' | `'smooth'` (the default) or `'auto'`. Reduced motion always jumps. |
| severity | Severity | — |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Emits
| Event | Payload | Description |
|---|---|---|
| click | event: MouseEvent | — |