Vuetify Toast Snackbar Demo
In this tutorial, we'll create a Vuetify toast snackbar that displays a message for 10 seconds. We'll walk through the code you provided to understand how it works and demonstrate its functionality.
written
reviewed
updated
Thanks for your feedback!
Your contributions will help us to improve service.
Code Explanation
Let's break down the code
Copied to Clipboard
- The
v-appandv-containerelements are part of Vuetify's layout structure. - The
v-snackbarcomponent is used to display the toast message. Itsv-modelis bound to thesnackbardata property, controlling its visibility. - The
:timeout="10000"attribute sets the timeout for the snackbar to 10 seconds. - Inside the snackbar,
{{ snackbarText }}is used to display the text. - The
v-btnelement is used to close the snackbar when clicked, settingsnackbartofalse. - Another
v-btntriggers theshowSnackbarmethod when clicked
Copied to Clipboard
- We use Vue.js to create the app.
datacontains thesnackbarproperty to control the snackbar's visibility andsnackbarTextfor the message.- The
showSnackbarmethod setssnackbartotrue, displaying the snackbar. - We use Vuetify to enhance the app's UI.
- Finally, we mount the app to the HTML element with the ID "app."
Conclusion
With this code, when you click the "Show Toast for 10 Seconds" button, the snackbar appears with the message "My timeout is set to 10000." It will automatically disappear after 10 seconds.
This Vuetify toast snackbar is a useful UI component for displaying temporary messages or notifications in your Vue.js applications
Output of Vuetify Toast Notification

Ad