# Toast

> A notification system: call toast() from anywhere to queue one, mount <Toaster /> once to render the stack — success, error, info and loading variants, an optional action, and accessible live-region announcements.

- Package: `fancy-ui-vue` (Vue 3.5+ + Tailwind CSS v4)
- Category: Overlays
- Tags: overlay, toast, notification, snackbar, live-region, accessibility
- Types: `ToastProps`, `ToasterProps`, `ToasterPosition`, `ToastVariant`, `ToastAction`, `ToastCloseReason`, `ToastOptions`, `ToastItem`
- Docs: https://fancy-ui.rama.app/docs/components/toast
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/vue/src/components/toast

## Import

```vue
<script setup lang="ts">
import { Toast } from 'fancy-ui-vue';
</script>
```

Setup (once per project): `npm install fancy-ui-vue`, then put these lines in your main CSS file (the stylesheet imports go right after `@import "tailwindcss";`):

```css
@import "tailwindcss";
@import "fancy-ui-vue/tailwind.css";
@import "fancy-ui-vue/styles.css";
```

Full guide: https://fancy-ui.rama.app/llms.txt

The names below are the ones to write in a Vue template; when one differs from the Svelte name, the Svelte name follows in parentheses. Snippets become named slots (`#default` is the default snippet), a prop the Vue port declares as a model is a `v-model:<name>` (except `ref`, exposed via `defineExpose({ ref })`: put a template ref on the component and read `.ref`) and callbacks are listeners (`onclick` is `@click`). Every component sets `inheritAttrs: false`: `class` is a declared prop, merged where the Svelte component applies it (not always the root element), and only when the props table below lists it; other attributes do not fall through unless the package README lists the component as forwarding native attributes. Divergences: https://github.com/RamaHerbin/fancy-ui/tree/main/vue#divergences-from-the-svelte-api

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `position` | `"top-left" \| "top-center" \| "top-right" \| "bottom-left" \| "bottom-center" \| "bottom-right"` | `"bottom-right"` | Corner (or edge-center) the <Toaster /> stack anchors to |
| `class` | `string` | — | Additional classes for the viewport that stacks the toasts |
| `ref` | `HTMLDivElement \| null` | `null` | Bindable reference to the <Toaster /> root node |
| `sound` | `boolean` | `false` | Plays success or error when a toast of that variant appears, once the user has enabled sound |
| `toast().title` (required) | `string` | — | Primary line of the toast raised by the toast() function |
| `toast().description` | `string` | — | Secondary line, shown under the title |
| `toast().variant` | `"success" \| "error" \| "info" \| "loading"` | `"info"` | Icon, accent colour, and the live region it announces through — error is assertive, everything else polite |
| `toast().duration` | `number` | `5000` | Milliseconds before auto-dismiss; Infinity is sticky. Defaults to Infinity for the loading variant, which has no natural finish time |
| `toast().action` | `{ label: string; onClick: () => void }` | — | A single action button. Auto-dismiss pauses on hover or focus for every toast, with or without one |

## Example

```vue
<script setup lang="ts">
import { Button, Toaster, toast } from "fancy-ui-vue";

function show() {
	toast({
		title: "Theme saved",
		description: "CSS copied to the clipboard.",
		variant: "success",
	});
}
</script>

<template>
	<Toaster sound />
	<Button :onclick="show">Show toast</Button>
</template>
```
