Notiwind
A headless Vue 3 notification library to use with Tailwind CSS. This is a fork and port of vue3-vt-notifications created and modified by killmenot to support Vue 3. Initially created by sansil.
? Features
- 100% Customizable
- Composition API support
- Create different groups of notifications
- Tailwind's JIT support
⚡️ Installation
or
You can then register Notifications
as a Vue plugin:
? How to use
Add the notification components to your main layout or in App.vue
:
Then, trigger notifications from your .vue
files:
Options API
Composition API
Basic example
For example in your App.vue
Then in any of your .vue
files:
The first argument is an object containing the data for the Notification
element, it's important to specify the group where the notificatoins are going to be displayed, the second argument is the timeout. The default timeout is 3 seconds.
Example with differents groups
You can use the NotificationGroup
component to have different types of notifications. For example, notifications error messages in top center and generic app notifications in bottom-right corner.
Then in any of your .vue
files:
Using different types of notifcations
You can render different types of notifications in the same group using a conditional, for example v-if="notification.type === 'info'"
Then in any of your .vue
files:
Props
Props for the Notification
component, all are opcional.
Name | Type | Default | Description |
---|---|---|---|
maxNotifications | Number | 10 | Maximum notifications displayed simultaneously |
enter | String | "" | enter-active-class transition classes. Applied during the entire entering phase. |
enterFrom | String | "" | enter-from-class transition classes. Starting state for enter. |
enterTo | String | "" | enter-to-class transition classes. Ending state for enter. |
leave | String | "" | leave-active-class transition classes. Applied during the entire leaving phase. |
leaveFrom | String | "" | leave-from-class transition classes. Starting state for leave. |
leaveTo | String | "" | leave-to-class transition classes. Ending state for leave. |
move | String | "" | move-class transition classes. Added when items are changing positions. |
moveDelay | String | "" | Delay between the position change. delay-300 recommended value. |
Check the Vue docs to know more about Enter & Leave Transitions and List Move Transitions.
Props for NotificationGroup
component, all are opcional.
Name | Type | Description |
---|---|---|
position | String | "bottom" or "top" are the posible values. |
group | String | Name of the group of notifications. |
Defualt scoped slots
Scope props:
Name | Type | Description |
---|---|---|
notifications | Array | Array of notification objects. |
close | Function | Closes the notification. Expects the notification ID as parameter |
Example
TODO
- Add tests
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
License
MIT