# Sonner
> Modern toast notifications — new in v0.3.0.
Source: https://shellui.dev/docs/v0.4/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
New in v0.4.0: `Clear()` dismisses every toast. A `duration` of `TimeSpan.Zero` keeps a toast open until it is dismissed.
```razor
@inject ISonnerService Sonner
```
## 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 |
| `Clear()` | Dismiss every toast (new in 0.4.0) |
| `Toasts` | The toasts currently shown |
`duration` defaults to 4 seconds; `TimeSpan.Zero` keeps the toast until it is dismissed.