# Toast

Source: https://ecosphere.dev/docs/feedback/toast (Ecosphere 1.5). Install `vue-ecosphere` for Vue 3 or `react-ecosphere` for React 18.2+/19: same components, props, markup and stylesheet.

Bottom-left toasts: a title you can read in half a second, plus an optional line that says what it means, in four status types.

`import { EcoToaster, EcoToast, useToast } from "vue-ecosphere"`

## Push a toast

Each button pushes a toast to the bottom-left stack. Confirmations dismiss themselves; failures stay until dismissed.

Vue (vue-ecosphere):

```vue
<!-- once, near the app root -->
<EcoToaster />

<script setup lang="ts">
import { useToast } from "vue-ecosphere";
const toast = useToast();

toast.success("Destination added", {
  description: "Primary cluster is receiving traffic. The first batch lands within a minute.",
});
toast.danger("Rotation failed", {
  description: "The old connection pool still holds four sessions. Nothing changed — retry once they drain.",
  action: "View log", onAction: openLog, duration: 0,   // 0 = stays until dismissed
});
toast.accent("Rebuilding search index", { description: "About nine minutes…" });
</script>
```

React (react-ecosphere):

```tsx
// once, near the app root
<EcoToaster />

// anywhere: a component, an event handler, a plain module
import { useToast } from "react-ecosphere";
const toast = useToast();

toast.success("Destination added", {
  description: "Primary cluster is receiving traffic. The first batch lands within a minute.",
});
toast.danger("Rotation failed", {
  description: "The old connection pool still holds four sessions. Nothing changed — retry once they drain.",
  action: "View log", onAction: openLog, duration: 0,   // 0 = stays until dismissed
});
toast.accent("Rebuilding search index", { description: "About nine minutes…" });
```

## Types

The left rule and icon carry the status; the surface stays white.

Vue (vue-ecosphere):

```vue
<EcoToast tone="success" title="Destination added"
  description="Primary cluster is receiving traffic. The first batch lands within a minute." />
<EcoToast tone="warning" title="Certificate expires in 6 days"
  description="Auto-renewal is off for api.internal, so this one needs a manual rotation." action="Renew now" />
<EcoToast tone="danger" title="Rotation failed" description="…" action="View log" />
<EcoToast tone="info" title="Export queued" description="…" />
```

React (react-ecosphere):

```tsx
<EcoToast tone="success" title="Destination added"
  description="Primary cluster is receiving traffic. The first batch lands within a minute." />
<EcoToast tone="warning" title="Certificate expires in 6 days"
  description="Auto-renewal is off for api.internal, so this one needs a manual rotation." action="Renew now" />
<EcoToast tone="danger" title="Rotation failed" description="…" action="View log" />
<EcoToast tone="info" title="Export queued" description="…" />
```

## Neutral, and title only

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `useToast()` | `{ push, success, warning, danger, info, accent, dismiss, clear, toasts }` | — | push(options) returns an id; the tone shortcuts take (title, options?). |
| `options.title` | `string` | — | A fact, not a sentence: “Rotation failed”. |
| `options.description` | `string` | — | What did not happen and what to do. Drop it for “Record saved”. |
| `options.tone` | `"success" \| "warning" \| "danger" \| "info" \| "accent"` | "accent" | Maps to toast--*; accent has no modifier (progress). Each tone has a fixed icon. |
| `options.action / onAction` | `string / () => void` | — | One action link at most; clicking it runs onAction and dismisses. |
| `options.duration` | `number` | 6000 | Auto-dismiss in ms. 0 keeps it until dismissed. |
| `<EcoToaster>` | `component` | — | The fixed bottom-left toasts stack, newest at the bottom. Mount once. The stack is the polite live region that reads each toast out. |
| `<EcoToast>` | `component` | — | One toast: title, description, tone, icon?, action, dismissible, leaving, live (role="status", default true; the toaster sets false); emits dismiss and action. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `useToast()` | `{ push, success, warning, danger, info, accent, dismiss, clear, toasts }` | — | push(options) returns an id; the tone shortcuts take (title, options?). Callable anywhere, not only in components; toasts is the queue at the moment you read it (EcoToaster is what re-renders). |
| `options.title` | `string` | — | A fact, not a sentence: “Rotation failed”. |
| `options.description` | `string` | — | What did not happen and what to do. Drop it for “Record saved”. |
| `options.tone` | `"success" \| "warning" \| "danger" \| "info" \| "accent"` | "accent" | Maps to toast--*; accent has no modifier (progress). Each tone has a fixed icon. |
| `options.action / onAction` | `string / () => void` | — | One action link at most; clicking it runs onAction and dismisses. |
| `options.duration` | `number` | 6000 | Auto-dismiss in ms. 0 keeps it until dismissed. |
| `<EcoToaster>` | `component` | — | The fixed bottom-left toasts stack, newest at the bottom. Mount once; to is a CSS selector for the portal target (default body). |
| `<EcoToast>` | `component` | — | One toast: title, description (or children), tone, icon?, action (text, or a node that replaces the link), dismissible, leaving; onDismiss and onAction. |
