How headless Notivue works with custom components
mainNotivue provides a headless API, meaning you can use your own custom UI components instead of the built-in <Notification />.
When using <Notivue v-slot="item">, the item object provides the necessary data for accessibility and interaction:
item.message: The notification text.item.ariaRole: The appropriate ARIA role.item.ariaLive: The ARIA live property.item.clear: A function to dismiss the notification.
<script setup>
import { Notivue, push } from 'notivue'
</script>
<template>
<button @click="push.success('Hi! I am your first notification!')">Push</button>
<Notivue v-slot="item">
<!-- Your custom notification component -->
<div class="rounded-full flex py-2 pl-3 bg-slate-700 text-slate-50 text-sm">
<p :role="item.ariaRole" :aria-live="item.ariaLive" aria-atomic="true">
{{ item.message }}
</p>
<button
@click="item.clear"
aria-label="Dismiss"
class="pl-3 pr-2 hover:text-red-300 transition-colors"
tabindex="-1"
>
<!-- Icon here -->
</button>
</div>
</Notivue>
</template>