{"id":35281,"date":"2024-10-17T18:25:20","date_gmt":"2024-10-17T16:25:20","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/?p=35281"},"modified":"2024-10-17T18:36:03","modified_gmt":"2024-10-17T16:36:03","slug":"creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/","title":{"rendered":"Creating a Global and Custom Snackbar in Vue 3 Using Vuetify and Pinia"},"content":{"rendered":"\n<p>In this post, we&#8217;ll walk through how to implement a Global and Custom Snackbar in Vue 3 with Vuetify and Pinia for state management. We&#8217;ll set it up so that you can easily trigger the Snackbar from any component in your app.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-i-set-up-your-vue-app-with-vuetify-cli\">I. Set Up Your Vue App with Vuetify CLI<\/h2>\n\n\n\n<p>To start, we\u2019ll create our Vue 3 app using the Vuetify CLI. This CLI simplifies the process of integrating Vuetify and sets up your project structure. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnpm create vuetify@latest\n<\/pre><\/div>\n\n\n<p>Follow the prompts to choose your project settings and install dependencies. As we are going to use Pinia, don&#8217;t forget to choose this option. I decided to keep all the generated files to keep it simple and straightforward, but you can clean the code that was automatically generated. I just cleaned the component HelloWorld.vue, that now looks like this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\n&lt;template&gt;\n  &lt;v-container class=&quot;fill-height&quot;&gt;\n    &lt;v-responsive class=&quot;align-centerfill-height mx-auto&quot; max-width=&quot;900&quot;&gt;\n    &lt;\/v-responsive&gt;\n  &lt;\/v-container&gt;\n&lt;\/template&gt;\n\n&lt;script setup lang=&quot;ts&quot;&gt;\n&lt;\/script&gt;\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-ii-set-up-the-pinia-store-for-snackbar\">II. Set Up the Pinia Store for Snackbar<\/h2>\n\n\n\n<p>Next, create a Pinia store (<code>SnackbarStore.ts<\/code>) to handle the state of the Snackbar (open\/close, message, status, etc.). This will allow you to trigger the Snackbar from anywhere in the app.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\n\/\/ SnackbarStore.ts inside stores directory\n\nimport { defineStore } from &#039;pinia&#039;\nimport { Ref, ref } from &#039;vue&#039;\n\nexport interface CustomAction {\n  actionName: string;\n  link: any;\n}\n\nexport const useSnackbarStore = defineStore(&#039;SnackbarStore&#039;, () =&gt; {\n  const isOpen = ref(false)\n  const message = ref(&#039;&#039;)\n  const status = ref(&#039;error&#039;)\n  const customActions: Ref&lt;CustomAction&#x5B;]&gt; = ref(&#x5B;])\n\n  const showSnackbar = (msg: string, st: string, optionalActions?: CustomAction&#x5B;]) =&gt; { \/\/ Change to accept an array\n    message.value = msg\n    status.value = st\n    isOpen.value = true\n    if (optionalActions) {\n      customActions.value.push(...optionalActions) \/\/ Spread the array into customActions\n    }\n    if (status.value.toLowerCase() === &#039;success&#039;) {\n      setTimeout(() =&gt; {\n        closeSnackbar()\n      }, 2500)\n    }\n  }\n\n  function closeSnackbar () {\n    isOpen.value = false\n    customActions.value.splice(0, customActions.value.length) \/\/ Clear custom actions\n  }\n\n  return { isOpen, message, status, showSnackbar, closeSnackbar, customActions }\n})\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-iii-create-the-snackbar-component\">III. Create the Snackbar Component<\/h2>\n\n\n\n<p>We&#8217;ll create a reusable Snackbar component (<code>GlobalSnackbar.vue<\/code>) that can be used anywhere in your application.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\n&lt;template&gt;\n  &lt;div class=&quot;text-center&quot;&gt;\n    &lt;v-snackbar\n      v-model=&quot;snackbarRef&quot;\n      class=&quot;customSnackbar&quot;\n      :color=&quot;snackbarStatus&quot;\n      variant=&quot;outlined&quot;\n      vertical\n    &gt;\n      &lt;div class=&quot;text-subtitle-1 pb-2 title-custom&quot;&gt;{{ snackbarStatus }}&lt;\/div&gt;\n\n      &lt;p&gt;{{ errorMsg }}&lt;\/p&gt;\n\n      &lt;template #actions&gt;\n        &lt;v-btn\n          v-for=&quot;act of snackbarActions&quot;\n          :key=&quot;act.actionName&quot;\n          :to=&quot;act.link&quot;\n        &gt;\n          {{ act.actionName }}\n        &lt;\/v-btn&gt;\n        &lt;v-btn variant=&quot;tonal&quot; @click=&quot;closeSnackbar&quot;&gt; Close &lt;\/v-btn&gt;\n      &lt;\/template&gt;\n    &lt;\/v-snackbar&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;\n\n&lt;script lang=&quot;ts&quot; setup&gt;\n  import { toRef } from &#039;vue&#039;\n  import { CustomAction, useSnackbarStore } from &#039;@\/stores\/SnackbarStore&#039;\n\n  \/\/ Define the properties that the component will receive\n  const props = defineProps({\n    snackbarShow: Boolean,\n    errorMsg: String,\n    snackbarStatus: String,\n    snackbarActions: {\n      type: Array as () =&gt; CustomAction&#x5B;], \/\/ Custom type to define snackbar actions\n    },\n  })\n\n  const snackbar = useSnackbarStore()\n  const snackbarRef = toRef(props, &#039;snackbarShow&#039;)\n\n  const closeSnackbar = () =&gt; {\n    snackbar.closeSnackbar()\n  }\n&lt;\/script&gt;\n\n&lt;style&gt;\n.customSnackbar.v-snackbar--vertical .v-snackbar__wrapper {\n  background-color: rgb(238, 238, 238);\n}\n.title-custom {\n  text-transform: uppercase !important;\n}\n&lt;\/style&gt;\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-iv-modify-app-vue-to-include-the-global-snackbar\">IV. Modify <code>App.vue<\/code> to Include the Global Snackbar<\/h2>\n\n\n\n<p>To ensure the Snackbar is available across your entire app, import it into <code>App.vue<\/code> and pass the required props from the <code>SnackbarStore<\/code>.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\n&lt;template&gt;\n  &lt;v-app&gt;\n    &lt;v-main&gt;\n      &lt;router-view \/&gt;\n    &lt;\/v-main&gt;\n    &lt;GlobalSnackbar\n      :error-msg=&quot;snackbar.message&quot;\n      :snackbar-actions=&quot;snackbar.customActions&quot;\n      :snackbar-show=&quot;snackbar.isOpen&quot;\n      :snackbar-status=&quot;snackbar.status&quot;\n    \/&gt;\n  &lt;\/v-app&gt;\n&lt;\/template&gt;\n\n&lt;script lang=&quot;ts&quot; setup&gt;\n  import { useSnackbarStore } from &#039;@\/stores\/SnackbarStore&#039;\n  const snackbar = useSnackbarStore()\n&lt;\/script&gt;\n<\/pre><\/div>\n\n\n<p>This step is essential to making sure the <code>GlobalSnackbar<\/code> component is part of the root layout and is always available to display messages.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-v-using-the-snackbar-in-a-component\">V. Using the Snackbar in a Component<\/h2>\n\n\n\n<p>Now, let&#8217;s demonstrate how to trigger the Snackbar from any component. For this example, we\u2019ll use a button that, when clicked, shows a success message with an optional action. We can edit HelloWord.vue with following code.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\n&lt;template&gt;\n  &lt;v-container class=&quot;fill-height&quot;&gt;\n    &lt;v-responsive class=&quot;align-centerfill-height mx-auto&quot; max-width=&quot;900&quot;&gt;\n      &lt;v-btn @click=&quot;openSnackbar()&quot;&gt;test&lt;\/v-btn&gt;\n    &lt;\/v-responsive&gt;\n  &lt;\/v-container&gt;\n&lt;\/template&gt;\n\n&lt;script setup lang=&quot;ts&quot;&gt;\n  import { useSnackbarStore } from &#039;@\/stores\/SnackbarStore&#039;\n  const snackbar = useSnackbarStore()\n\n  const openSnackbar = () =&gt; {\n    snackbar.showSnackbar(&#039;Show snackbar&#039;, &#039;success&#039;, &#x5B;\n      { actionName: &#039;Go to Home&#039;, link: &#039;\/home&#039; },\n      { actionName: &#039;Go to Test&#039;, link: &#039;\/test&#039; },\n    ])\n  }\n&lt;\/script&gt;\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-vi-testing-the-snackbar\">VI. Testing the Snackbar<\/h2>\n\n\n\n<p>Once everything is in place, try clicking the button to trigger the Snackbar. You should see the Snackbar with a success message and an optional action button appear at the bottom of the screen. And Logically, if you click on one of the custom action buttons, it will redirect you properly, but you will obviously see a blank page, as the view doesn&#8217;t exist.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"521\" height=\"493\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/10\/image-49.png\" alt=\"\" class=\"wp-image-35295\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/10\/image-49.png 521w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/10\/image-49-300x284.png 300w\" sizes=\"auto, (max-width: 521px) 100vw, 521px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n\n\n\n<p>In this post, we created a global and custom Snackbar component in Vue 3 using Vuetify and Pinia. We set it up so that it can be easily triggered from anywhere in the app. By managing its state with Pinia, we keep the logic centralized and clean, making the Snackbar reusable across the entire application.<\/p>\n\n\n\n<p>Feel free to adjust the styling and functionality of the Snackbar to suit your needs. Now you have a flexible, easy-to-use notification system for your Vue 3 project!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, we&#8217;ll walk through how to implement a Global and Custom Snackbar in Vue 3 with Vuetify and Pinia for state management. We&#8217;ll set it up so that you can easily trigger the Snackbar from any component in your app. I. Set Up Your Vue App with Vuetify CLI To start, we\u2019ll create [&hellip;]<\/p>\n","protected":false},"author":87,"featured_media":33232,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3029],"tags":[3443,437,3032,3442,3034,3035,3358],"type_dbi":[3040,3039,3038,3359],"class_list":["post-35281","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web","tag-global","tag-global-page","tag-pinia","tag-snackbar","tag-vue","tag-vuejs","tag-vuetify","type-pinia","type-vue","type-vuejs","type-vuetify"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Creating a Global and Custom Snackbar in Vue 3 Using Vuetify and Pinia - dbi Blog<\/title>\n<meta name=\"description\" content=\"Learn how to create a global &amp; Custom Snackbar in Vue 3 using Vuetify and Pinia. This tutorial walks you through setup, state management, and triggering notifications from any component.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating a Global and Custom Snackbar in Vue 3 Using Vuetify and Pinia\" \/>\n<meta property=\"og:description\" content=\"Learn how to create a global &amp; Custom Snackbar in Vue 3 using Vuetify and Pinia. This tutorial walks you through setup, state management, and triggering notifications from any component.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2024-10-17T16:25:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-17T16:36:03+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/05\/Logo-Vuejs-e1716299720267.png\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"180\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Joan Frey\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Joan Frey\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\\\/\"},\"author\":{\"name\":\"Joan Frey\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/c03c47649664fe73b27ce457e99f5b06\"},\"headline\":\"Creating a Global and Custom Snackbar in Vue 3 Using Vuetify and Pinia\",\"datePublished\":\"2024-10-17T16:25:20+00:00\",\"dateModified\":\"2024-10-17T16:36:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\\\/\"},\"wordCount\":455,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/Logo-Vuejs-e1716299720267.png\",\"keywords\":[\"global\",\"Global page\",\"Pinia\",\"snackbar\",\"vue\",\"vuejs\",\"vuetify\"],\"articleSection\":[\"Web\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\\\/\",\"name\":\"Creating a Global and Custom Snackbar in Vue 3 Using Vuetify and Pinia - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/Logo-Vuejs-e1716299720267.png\",\"datePublished\":\"2024-10-17T16:25:20+00:00\",\"dateModified\":\"2024-10-17T16:36:03+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/c03c47649664fe73b27ce457e99f5b06\"},\"description\":\"Learn how to create a global & Custom Snackbar in Vue 3 using Vuetify and Pinia. This tutorial walks you through setup, state management, and triggering notifications from any component.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/Logo-Vuejs-e1716299720267.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/Logo-Vuejs-e1716299720267.png\",\"width\":300,\"height\":180,\"caption\":\"Logo-Vuejs\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Creating a Global and Custom Snackbar in Vue 3 Using Vuetify and Pinia\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/c03c47649664fe73b27ce457e99f5b06\",\"name\":\"Joan Frey\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g\",\"caption\":\"Joan Frey\"},\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/joanfrey\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Creating a Global and Custom Snackbar in Vue 3 Using Vuetify and Pinia - dbi Blog","description":"Learn how to create a global & Custom Snackbar in Vue 3 using Vuetify and Pinia. This tutorial walks you through setup, state management, and triggering notifications from any component.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/","og_locale":"en_US","og_type":"article","og_title":"Creating a Global and Custom Snackbar in Vue 3 Using Vuetify and Pinia","og_description":"Learn how to create a global & Custom Snackbar in Vue 3 using Vuetify and Pinia. This tutorial walks you through setup, state management, and triggering notifications from any component.","og_url":"https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/","og_site_name":"dbi Blog","article_published_time":"2024-10-17T16:25:20+00:00","article_modified_time":"2024-10-17T16:36:03+00:00","og_image":[{"width":300,"height":180,"url":"http:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/05\/Logo-Vuejs-e1716299720267.png","type":"image\/png"}],"author":"Joan Frey","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Joan Frey","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/"},"author":{"name":"Joan Frey","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/c03c47649664fe73b27ce457e99f5b06"},"headline":"Creating a Global and Custom Snackbar in Vue 3 Using Vuetify and Pinia","datePublished":"2024-10-17T16:25:20+00:00","dateModified":"2024-10-17T16:36:03+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/"},"wordCount":455,"commentCount":0,"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/05\/Logo-Vuejs-e1716299720267.png","keywords":["global","Global page","Pinia","snackbar","vue","vuejs","vuetify"],"articleSection":["Web"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/","url":"https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/","name":"Creating a Global and Custom Snackbar in Vue 3 Using Vuetify and Pinia - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/#primaryimage"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/05\/Logo-Vuejs-e1716299720267.png","datePublished":"2024-10-17T16:25:20+00:00","dateModified":"2024-10-17T16:36:03+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/c03c47649664fe73b27ce457e99f5b06"},"description":"Learn how to create a global & Custom Snackbar in Vue 3 using Vuetify and Pinia. This tutorial walks you through setup, state management, and triggering notifications from any component.","breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/#primaryimage","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/05\/Logo-Vuejs-e1716299720267.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2024\/05\/Logo-Vuejs-e1716299720267.png","width":300,"height":180,"caption":"Logo-Vuejs"},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/creating-a-global-snackbar-in-a-vue-3-application-using-vuetify-and-pinia\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Creating a Global and Custom Snackbar in Vue 3 Using Vuetify and Pinia"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/c03c47649664fe73b27ce457e99f5b06","name":"Joan Frey","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1e650cf665b4d44dd186355827c0b049d2f95c8cbb45fd10d4e7cb255be67ecb?s=96&d=mm&r=g","caption":"Joan Frey"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/joanfrey\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/35281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=35281"}],"version-history":[{"count":15,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/35281\/revisions"}],"predecessor-version":[{"id":35309,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/35281\/revisions\/35309"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media\/33232"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=35281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=35281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=35281"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=35281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}