Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
vue-3-scroll-to-top-button
Advanced tools
Vue.js 3 component to scroll on the top on the page, with good animation and UI
A Vue.js component for a floating action button (FAB) that scrolls the page to the top.
Install the package using npm or yarn:
npm install vue-3-scroll-to-top-button
# or
yarn add vue-3-scroll-to-top-button
By default, the button will be on the bottom left, you can play with the options to customize it or positionnate it.
<script setup lang="ts">
import { ScrollToTopButton } from 'vue-3-scroll-to-top-button';
import 'vue-3-scroll-to-top-button/style.css';
</script>
<template>
<ScrollToTopButtonVue />
</template>
You can for example pass props to positionnate relatively the button
<script setup lang="ts">
import { ScrollToTopButton } from 'vue-3-scroll-to-top-button';
import 'vue-3-scroll-to-top-button/style.css';
</script>
<template>
<ScrollToTopButtonVue
noTeleport
:showButtonTreshold="0"
:style="{ position: 'relative' }"
/>
</template>
Or you can take advantage of the slot to pass a custom icon, or play with the detection treshold
<script setup lang="ts">
import { ScrollToTopButton } from 'vue-3-scroll-to-top-button';
import 'vue-3-scroll-to-top-button/style.css';
</script>
<template>
<div>
<ScrollToTopButtonVue
:showButtonTreshold="300"
position="top"
class="custom-button"
backgroundColor="yellow"
iconColor="blue"
>
<template #icon>
<svg viewBox="0 0 24 24" width="48px" height="48px" fill="#ffffff" xmlns="http://www.w3.org/2000/svg">
<path d="M12 2L3 12h4v8h10v-8h4z" />
</svg>
</template>
</ScrollToTopButtonVue>
</div>
</template>
<style>
.custom-button {
height: 100px;
}
</style>
Name | Type | Description |
---|---|---|
anchor | (string) | The target element to which the button will be teleported. Defaults to 'body'. |
iconColor | (string) | The color of the button icon. Defaults to 'white'. |
backgroundColor | (string) | The background color of the button. Defaults to '#2C3436'. |
showButtonTreshold | (number) | The scroll threshold at which the button becomes visible. Defaults to 1. |
withAnimation | (boolean) | Enables or disables the transition animation. Defaults to true. |
size | (ButtonSize) | The size of the button. Can be 'small', 'medium', or 'large'. Defaults to 'medium'. |
position | (ButtonPosition) | The position of the button. Can be 'top-left', 'top', 'top-right', 'right', 'bottom-right', 'bottom', 'bottom-left', or 'left'. Defaults to 'bottom-right'. |
noTeleport | (boolean) | Disables teleporting the button to a specified anchor. Defaults to false. |
marginFromSide | (string) | The margin from the side when using noTeleport. Defaults to '12px'. |
The component is fully written in typescript so you have the best autocompletion Here are the types of the props so you can manipulate it.
export type ButtonSize = 'small' | 'medium' | 'large'
export type ButtonPosition = 'top-left'
| 'top'
| 'top-right'
| 'right'
| 'bottom-right'
| 'bottom'
| 'bottom-left'
| 'left'
export interface ScrollToTopButtonProps {
anchor?: string
iconColor?: string
backgroundColor?: string
showButtonTreshold?: number
withAnimation?: boolean
size?: ButtonSize
position?: ButtonPosition
noTeleport?: boolean
marginFromSide?: string
}
The component is designed to be accessible with proper ARIA attributes and roles. The button is given an aria-label of "Scroll to Top" and a role of "button" to enhance accessibility.
The button features a smooth transition effect when appearing or disappearing, enhancing the user experience.
This project is licensed under the MIT License - see the LICENSE file for details.
Thanks to Anatole Acqueberge for creating this amazing Vue 3 confettis plugin! Feel free to contribute, report issues, or suggest improvements. Happy coding! 🎉
FAQs
Vue.js 3 component to scroll on the top on the page, with good animation and UI
The npm package vue-3-scroll-to-top-button receives a total of 1 weekly downloads. As such, vue-3-scroll-to-top-button popularity was classified as not popular.
We found that vue-3-scroll-to-top-button demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.