# Sonner
> Modern toast notifications — new in v0.3.0.
Source: https://shellui.dev/docs/v0.3/components/advanced/sonner
`Sonner` is **new in v0.3.0**. It provides shadcn-style stacked toast notifications via a `SonnerService` injectable service.
## Installation
```bash
shellui add sonner
```
`sonner-variants` and `sonner-service` are auto-installed as dependencies.
## Usage
Inject `SonnerService` in any component:
```razor
@inject SonnerService SonnerService
@* Usually placed once in MainLayout.razor *@
```
### Dismiss all toasts
```razor
@inject ISonnerService Sonner
@code {
private void DismissAll()
{
foreach (var toast in Sonner.Toasts.ToList())
Sonner.Remove(toast.Id);
}
}
```
## Setup
### 1. Register the service
In `Program.cs`:
```csharp
using ShellUI.Components.Services;
builder.Services.AddSonner();
```
### 2. Add `` to your layout
Place it once at the top level, e.g. `MainLayout.razor`:
```razor
@using ShellUI.Components
@Body
```
## Position options
```razor
@* Bottom right (common for apps) *@
@* Top center (common for docs/alerts) *@
```
## API Reference
### ``
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `Position` | `SonnerPosition` | `TopCenter` | Where toasts appear on screen |
### `SonnerPosition` enum
| Value | Position |
|-------|----------|
| `TopLeft` | Top-left corner |
| `TopCenter` | Top-center |
| `TopRight` | Top-right corner |
| `BottomLeft` | Bottom-left corner |
| `BottomCenter` | Bottom-center |
| `BottomRight` | Bottom-right corner |
### `SonnerService` methods
| Method | Description |
|--------|-------------|
| `Show(message, description?, variant?, duration?)` | Display a toast. `variant` defaults to `"default"` |
| `Success(message, description?, duration?)` | Success toast |
| `Error(message, description?, duration?)` | Error toast |
| `Info(message, description?, duration?)` | Info toast |
| `Warning(message, description?, duration?)` | Warning toast |
| `Remove(id)` | Dismiss a specific toast by ID |
| `Toasts` | The toasts currently shown; remove each one to dismiss all |