Toast

Alignment target:@astryxdesign/core v0.7.1 · Toast

Document saved successfully

Usage #

Place ToastViewport once near the root of your app, then call useToast from any component.

On a touch screen, a swipe toward the toast's edge dismisses it: down when it sits at the bottom, up when it sits at the top. A horizontal drag is left to the page. A swipe that starts on a button or link does not dismiss. A mouse drag does not dismiss either.

Vue
<script setup lang="ts">
import { ToastViewport, useToast } from '@astryx-vue/core/Toast'

const toast = useToast()

toast({ body: 'Saved successfully', type: 'success' })
</script>

<template>
  <div>
    <button @click="toast({ body: 'Saved' })">
      Save
    </button>
    <ToastViewport />
  </div>
</template>

Anatomy

ElementDescription
BodyThe primary message text describing what happened or what the user should know.
End contentA trailing action like an Undo button or a link, placed after the body text.
Dismiss buttonA close button that lets the user manually dismiss the toast before auto-hide.

Best practices #

GuidancePractice
RecommendedPut ToastViewport at the top level so toasts overlay every page.
RecommendedUse type="error" for failures and rely on role="alert".
RecommendedKeep toast copy short — one line describing the outcome is enough.
Don'tFlood the screen with many toasts at once.
Don'tUse toasts for actions that need user confirmation.

Examples #

Toast — Action

Item deleted
Your report is ready.
Open in Playground

A persistent toast can end with a button or a link, for undoing a delete or opening a report.

Toast — Deduplication

You are offline
Open in Playground

uniqueID collapses repeats. ignore keeps the first toast; overwrite replaces it, for a progress percentage.

Toast — Dismiss

Uploading file…
Open in Playground

useToast returns a function that dismisses that toast. Use it when a long-running operation should close the notice itself.

Toast — Stacking

Changes saved.
Message sent to Sarah Chen.
Open in Playground

Toasts stack vertically and animate in and out. Clicking again queues another one.

Toast — Types

Changes saved successfully.
Open in Playground

Info and error side by side. Info goes away on its own; error stays until it is dismissed.