Skip to content

Toast

Usage ​

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

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>

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 ​

Basic

Click the buttons to trigger toasts of different types and durations.

Stack

Several toasts stack in the viewport and keep their order as they appear.