Gathering detailed insights and metrics for vue-snap-alert
Gathering detailed insights and metrics for vue-snap-alert
SnapAlert is a lightweight Vue 3 plugin that provides customizable and user-friendly alert notifications , Easily display alerts, confirmations, and prompts in your Vue applications with simple methods and flexible options.
npm install vue-snap-alert
Typescript
Module System
Node Version
NPM Version
72.3
Supply Chain
98.9
Quality
82.7
Maintenance
100
Vulnerability
100
License
Total Downloads
1,107
Last Day
1
Last Week
5
Last Month
24
Last Year
1,107
19 Commits
1 Watching
1 Branches
2 Contributors
Minified
Minified + Gzipped
Latest Version
1.1.2
Package Id
vue-snap-alert@1.1.2
Unpacked Size
31.18 kB
Size
7.69 kB
File Count
6
NPM Version
10.8.3
Node Version
22.9.0
Publised On
25 Oct 2024
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
0%
5
Compared to previous week
Last month
-27.3%
24
Compared to previous month
Last year
0%
1,107
Compared to previous year
No dependencies detected.
SnapAlert is a lightweight and customizable Vue 3 plugin designed for adding stylish alert notifications to your app. This plugin allows you to easily display alerts, confirmations, prompts, and even custom HTML notifications in a user-friendly way.
You can install the plugin via npm:
1npm install vue-snap-alert
Here's how to use SnapAlert in your Vue 3 project:
Add SnapAlert to your main Vue entry file (usually main.js
or main.ts
).
1import { createApp } from 'vue'; 2import App from './App.vue'; 3import SnapAlert from 'vue-snap-alert'; 4import 'vue-snap-alert/dist/snapAlert.css'; // Import the CSS 5 6const app = createApp(App); 7 8// Install the SnapAlert plugin 9app.use(SnapAlert); 10 11app.mount('#app');
You can now use SnapAlert to display different types of alerts. Here are some examples:
1this.$SnapAlert.alert('Alert Title', 'This is a basic alert.');
1this.$SnapAlert.success('Success', 'Your operation was successful!');
1this.$SnapAlert.info('Info', 'Be Notice!');
1this.$SnapAlert.error('Error', 'Something went wrong.');
1this.$SnapAlert.warning('Are you sure?', 'This action cannot be undone.', { 2 enableConfirm: true, 3 enableCancel: true, 4 onConfirm: () => { 5 console.log('Confirmed!'); 6 }, 7 onCancel: () => { 8 console.log('Cancelled!'); 9 } 10});
You can customize the options for each alert. For example:
1this.$SnapAlert.info('Information', 'This is an info alert.', { 2 position: 'top right', 3 duration: 5000, 4 icon: 'custom-icon-class', // Replace with a Boxicons class name (https://boxicons.com) 5 isDark: true 6});
You can display various types of alerts using the provided methods. Below is an example of how to show a custom HTML alert:
1this.$SnapAlert.html(`<img src="https://placehold.co/600x400" />`, { 2 position: 'top right', 3 duration: 5000, 4 } 5);
SnapOptions
You can use the SnapOptions
method to set global default options for all alerts. This is particularly useful if you want to maintain consistency across multiple alerts.
1this.$SnapAlert.SnapOptions({ 2 duration: 5000, 3 isDark: true, 4 position: 'bottom right' 5});
After setting global options, all subsequent alerts will use the specified default settings unless overridden by individual alert options:
1// Set global options 2this.$SnapAlert.SnapOptions({ 3 duration: 4000, 4 isDark: false, 5}); 6 7// Now all alerts will have these default settings 8this.$SnapAlert.success('Global Success', 'This alert will use global options.'); 9this.$SnapAlert.error('Global Error', 'This alert will also use global options.');
clearAll
The clearAll
method is used to remove all active alerts from the screen. This can be useful in scenarios where you want to clear multiple notifications at once, such as when navigating away from a page, or after performing a certain action where notifications are no longer relevant.
1this.$SnapAlert.clearAll();
This will instantly clear all alerts, including success, error, warning, info, and custom HTML alerts, if any are currently visible.
false
(Enable/disable right-to-left support)'info'
, 'success'
, 'error'
, 'warning'
'top left'
, 'top right'
, 'bottom left'
, 'bottom right'
, 'top center'
, 'bottom center'
.true
)false
)false
)false
)This project is licensed under the MIT License - see the LICENSE file for details.
No vulnerabilities found.
No security vulnerabilities found.