# SbToast
A temporary notification message that appears briefly to provide feedback about an operation. Toasts auto-dismiss and can show various severity levels. Typically used via SbToastHost for proper positioning and management.
## Parameters
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| Title | string? | null | Toast title/heading |
| Message | string? | null | Toast message text (used when ChildContent is not provided) |
| Severity | SbToastSeverity | Info | Toast severity (Info, Success, Warning, Error) |
| ShowCloseButton | bool | true | Whether to show the close button |
| Class | string? | null | Additional CSS classes |
## Events
| Event | Type | Description |
|-------|------|-------------|
| OnClose | EventCallback | Fired when the toast is closed |
## Templates / Slots
| Slot | Type | Description |
|------|------|-------------|
| ChildContent | RenderFragment? | Custom content (takes precedence over Message) |
### Template Usage
```razor
Your profile has been updated.
View Profile
```
## CSS Classes
- `sb-toast` - Base class
- `sb-toast--info` - Info severity
- `sb-toast--success` - Success severity
- `sb-toast--warning` - Warning severity
- `sb-toast--error` - Error severity
- `sb-toast__icon` - Icon container
- `sb-toast__content` - Content wrapper
- `sb-toast__title` - Title text
- `sb-toast__message` - Message text
- `sb-toast__close` - Close button
## Accessibility
- Uses `role="alert"` for important notifications
- Uses `aria-live="polite"` for non-intrusive announcements
- Close button has `aria-label="Close"`
## Examples
### Basic Toast (Standalone)
```razor
```
### With Title
```razor
```
### With Custom Content
```razor
You have a new message from John.
View
```
### Without Close Button
```razor
```
### Handling Close
```razor
@code {
private void HandleClose()
{
Console.WriteLine("Toast closed");
}
}
```
## Recommended Usage with SbToastHost
For proper toast management (positioning, stacking, auto-dismiss), use `SbToastHost`:
```razor
@* In your layout or main component *@
@* Trigger toasts from your component *@
Show Success
@code {
private SbToastHost? toastHost;
private async Task ShowSuccessToast()
{
await toastHost!.ShowSuccessAsync("Operation completed!", "Success");
}
}
```
See `SbToastHost` documentation for full details on toast management.