Snackbar
Headless compound component for toast and snackbar notifications. Pairs with useNotifications for queue-driven stacks with auto-dismiss and pause on hover.
Usage
A single snackbar — render directly when you control the lifecycle yourself.
Anatomy
<script setup lang="ts">
import { Snackbar } from '@vuetify/v0'
</script>
<template>
<Snackbar.Portal>
<Snackbar.Queue>
<Snackbar.Root>
<Snackbar.Content />
<Snackbar.Close />
</Snackbar.Root>
</Snackbar.Queue>
<Snackbar.Announcer />
</Snackbar.Portal>
</template>Examples
- Q3-report.pdf
- design-spec.fig
- budget.xlsx
Cycles through info → success → warning → error
Recipes
Teleport target
Snackbar.Portal defaults to teleport="top-layer" so snackbars work automatically when a modal dialog is open. Pass an explicit value to override:
<template>
<!-- Default: mounts inside the topmost open modal, falls back to body -->
<Snackbar.Portal><!-- ... --></Snackbar.Portal>
<!-- Always teleport to body, even inside a modal -->
<Snackbar.Portal teleport="body"><!-- ... --></Snackbar.Portal>
<!-- Render inline — no teleport (useful in scoped containers, Storybook) -->
<Snackbar.Portal :teleport="false"><!-- ... --></Snackbar.Portal>
</template>ARIA role
Set role directly on Snackbar.Root to control how screen readers announce the notification:
<template>
<!-- Polite — waits for user to be idle -->
<Snackbar.Root role="status">
<Snackbar.Content>Changes saved</Snackbar.Content>
<Snackbar.Close />
</Snackbar.Root>
<!-- Assertive — interrupts immediately -->
<Snackbar.Root role="alert">
<Snackbar.Content>Build failed — check logs</Snackbar.Content>
<Snackbar.Close />
</Snackbar.Root>
</template>Inline rendering
Pass :teleport="false" to render the portal inline instead of teleporting to <body>. Useful in docs, Storybook, or scoped container layouts:
<template>
<div class="relative h-48">
<Snackbar.Portal :teleport="false" class="absolute bottom-4 right-4">
<Snackbar.Root>
<Snackbar.Content>Changes saved</Snackbar.Content>
<Snackbar.Close />
</Snackbar.Root>
</Snackbar.Portal>
</div>
</template>Accessibility
| Concern | Implementation |
|---|---|
| Live region | Snackbar.Portal auto-renders Snackbar.Announcer — a visually-hidden polite + assertive pair, mounted empty — and each Snackbar.Root mirrors its text into the matching region on mount, so the first message is reliably announced. Pass :announcer="false" to place <Snackbar.Announcer> yourself. Snackbar.Root still defaults to role="status" (role="alert" when urgent) as best-effort without a Portal. |
role="status" | Implicit aria-live="polite" — screen reader waits for idle. Use for confirmations and info. |
role="alert" | Implicit aria-live="assertive" — screen reader interrupts. Use for errors and warnings. |
| Close button | Snackbar.Close renders an inline default aria-label of "Dismiss", localizable via the Snackbar.close key. |
| Timing | Auto-dismiss pauses on hover and focus (WCAG 2.2.1). Tabbing into a snackbar pauses the queue; focus leaving the container resumes it. |
| Focus | No focus trap — snackbars are non-modal. |
FAQ
Use Snackbar.Queue for notifications flowing through useNotifications — you get auto-dismiss, pause-on-hover, and stacking. For a transient one-off message whose lifecycle you control yourself, render a Snackbar.Root without a queue.
Inside a queue, dismiss() removes the toast from the display queue only — the item survives in the registry (e.g. an inbox). Snackbar.Close permanently unregisters it from both the queue and the registry.
Set role="alert" on Snackbar.Root (implicit aria-live="assertive"). The default role="status" is polite and waits for the reader to be idle.
Yes. A queued stack pauses on hover and focus (WCAG 2.2.1) and resumes once focus leaves the container — no wiring needed.
Pass :teleport="false" on Snackbar.Portal, optionally inside a relative container, to render the stack in place. (By default Snackbar.Portal teleports to top-layer, falling back to <body> when no modal dialog is open.)
Attach a closure to the notification’s data payload when you send it. Snackbar.Queue exposes each ticket through its slot, so the host reads data.undo and renders an Undo button beside Snackbar.Close.