# Toast
> Sonner-style notifications that stack in a corner and dismiss themselves.
Source: https://native.shellui.dev/docs/components/feedback/toast
Call `Toast.Show` (or `Success`, `Error`, `Warning`, `Info`) from anywhere. Toasts float above the page, pause while hovered, and go after four seconds.
## Installation
```bash
shellui-native add toast
```
**Platforms:** MAUI ยท Avalonia. Also installs `icon`, `button`, `button-variants`.
## Usage
### Basic
**MAUI**
```xml
```
**Avalonia**
```xml
```
[Live preview](https://native.shellui.dev/preview/index.html?c=toast-basic)
```csharp
private void OnShow(object? sender, EventArgs e) =>
Toast.Show("Event has been created", "Sunday, December 03 at 9:00 AM");
private void OnSuccess(object? sender, EventArgs e) => Toast.Success("Profile saved");
private void OnError(object? sender, EventArgs e) =>
Toast.Error("Upload failed", "The file is larger than 10 MB.");
private void OnWarning(object? sender, EventArgs e) =>
Toast.Warning("Storage almost full", "92% of your quota used.");
```
## Action
A toast can carry one action button. Pressing it runs the action and dismisses the toast:
```csharp
Toast.Show("Message archived", actionText: "Undo", action: Unarchive);
```
## Position
Without a `Toaster`, toasts stack in the bottom-right corner, three at a time. Declare one anywhere to change that:
```xml
```
## MAUI and Avalonia
On MAUI the `Toaster` goes on a page; on Avalonia in a window. Without one, `Toast.Show` uses the page (MAUI) or window (Avalonia) on screen.
## API
### Toast
| Method | Description |
|---|---|
| `Toast.Show(string message, string? description = null, ToastVariant variant = ToastVariant.Default, TimeSpan? duration = null, string? actionText = null, Action? action = null)` | Shows a toast and returns its id. |
| `Toast.Success(string message, string? description = null, TimeSpan? duration = null, string? actionText = null, Action? action = null)` | Shows a success toast and returns its id. |
| `Toast.Error(string message, string? description = null, TimeSpan? duration = null, string? actionText = null, Action? action = null)` | Shows an error toast and returns its id. |
| `Toast.Warning(string message, string? description = null, TimeSpan? duration = null, string? actionText = null, Action? action = null)` | Shows a warning toast and returns its id. |
| `Toast.Info(string message, string? description = null, TimeSpan? duration = null, string? actionText = null, Action? action = null)` | Shows an info toast and returns its id. |
| `Toast.Dismiss(string id)` | Dismisses the toast with this id. |
### Toaster
| Property | Type | Default | Description |
|---|---|---|---|
| `Position` | `ToasterPosition` | `BottomRight` | Corner (or edge) the toasts stack in. One of `BottomRight`, `BottomCenter`, `TopRight`, `TopCenter`. |
| `MaxVisible` | `int` | `3` | Most toasts shown at once; older ones are dismissed. |