npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

v-snackbars

v3.2.8

Published

Display the v-snackbar (from Vuetify) with a stack display

Downloads

12,956

Readme

v-snackbars

Display the v-snackbar (from Vuetify) with a stack display

Capture

Requirements

Vuetify > v2.3 (it may work with an earlier version of Vuetify but I haven't tested)

Install

npm install v-snackbars

Demo

See it in action: https://codesandbox.io/s/v-snackbars-demo-8xrbr?file=/src/App.vue

How to use

import VSnackbars from "v-snackbars"
export default {
  components:{
    "v-snackbars": VSnackbars
  },
  […]
}
<v-snackbars :messages.sync="messages"></v-snackbars>

You need to provide a messages array. Using a push on the array will cause the text to be shown in a snackbar.

For example, to display "This is a message", just do the below:

this.messages.push("This is a message");

You can use the same options as the v-snackbar. For example:

<v-snackbars :messages.sync="messages" :timeout="10000" bottom left color="red"></v-snackbars>

Options

Snackbar Options

The same v-snackbar options should be applicable, like bottom, right, left, top, color, timeout, ….

Personalized content

You can use v-slot:default to customize the content of the snackbar.

For example:

<v-snackbars :messages.sync="messages" :timeout="-1" color="black" top right>
  <template v-slot:default="{ message, id, index }">
    <h3 class="mb-2">Header</h3>
    {{ message }}
  </template>
</v-snackbars>

The parameter:

  • message: the current message that is displayed in the notification
  • id: the unique key/id of the message
  • index: the index in the array of notifications/messages

Personalized button

A close button is used by default. If you prefer to define your own action button, you can use a v-slot:action.

For example:

<v-snackbars :messages.sync="messages" :timeout="-1" color="black" top right>
  <template v-slot:action="{ close, index, message, id }">
    <v-btn text @click="close()">Dismiss</v-btn>
  </template>
</v-snackbars>

By clicking on Dismiss, it will remove the related snackbar.

The parameters:

  • close: the function to remove a notification
  • index: the index in the array of notifications/messages
  • message: the current message that is displayed in the notification
  • id: the unique key/id of the message

Objects

If you want to customize each snackbar, you can also pass a objects instead of messages, which will contain the various props (like message, color, timeout, transition, contentClass or the position).

In the JavaScript code:

this.objects.push({
  message:"Success",
  color:"green",
  timeout:5000
})
this.objects.push({
  message:"Error",
  color:"red",
  timeout:-1
})

In your Vue template:

<v-snackbars :objects.sync="objects"></v-snackbars>

Check the "Random Toast" button on the demo.

Interactivity

You can add some layers of interactivity with the messages.

For example, you can change the text by doing:

this.$set(this.messages, i, "New message to display");

To remove a notification, you'll have to use splice:

this.messages.splice(i, 1);

Check the "Show Interactivity" button on the demo.