Toast
Application notification viewport powered by UiToastService.
- Selector
- ui-toast
- Package
- @ngnova/ui/toast
Import
import { UiToastComponent, UiToastService } from '@ngnova/ui/toast';Usage & variants
Live examples use the public ui-toast API, paired with the exact snippet a product team would paste into an Angular app.
Package saved notification
Application notification viewport powered by UiToastService.
Production guidance
Use these notes to decide when the component belongs in a product workflow and what to verify before shipping.
When to use
Use after background actions such as save, publish, upload, invite, or delete.
Watch for
Clear messages on route changes if stale notifications would confuse users.
Product recipes
Apply Toast in distinct, copyable product scenarios—not just an isolated component state.
Service usage
Render one viewport near the app root, configure its minimum edge offset, and push messages from features.
1 2 3 4 5 6 7 8
<ui-toast position="top-right" viewportOffset="1rem" />
private readonly toast = inject(UiToastService);
save(): void {
this.toast.success('Saved', 'Your changes are ready.');
this.toast.warning('Session ending', 'Save your work now.', 8000);
}Undo archive
Confirm a completed background action and offer a short-lived recovery path when appropriate.
1 2 3 4 5 6 7
<ui-button (pressed)="archiveProject()">Archive project</ui-button>
<!-- Component class -->
archiveProject(): void {
this.projects.archive(this.projectId);
this.toast.success('Project archived', 'The project moved to your archive.');
}API Reference
Inputs and outputs are semver-sensitive public API. Keep examples aligned with this table.
Inputs
position 'top-right' 'top-right' | 'bottom-right' | 'top-end' | 'bottom-end' Viewport placement. The -end values follow the text direction and mirror under dir="rtl".
viewportOffset 'var(--ui-toast-offset, 1rem)' string CSS length used as the minimum viewport inset; device safe-area insets take precedence when larger.
maxMessages 5 number Maximum number of newest messages rendered in the viewport.
dismissAriaLabel 'Dismiss notification' string Localized accessible label for every dismiss action.
| Name | Type | Default | Description |
|---|---|---|---|
position | 'top-right' | 'bottom-right' | 'top-end' | 'bottom-end' | 'top-right' | Viewport placement. The -end values follow the text direction and mirror under dir="rtl". |
viewportOffset | string | 'var(--ui-toast-offset, 1rem)' | CSS length used as the minimum viewport inset; device safe-area insets take precedence when larger. |
maxMessages | number | 5 | Maximum number of newest messages rendered in the viewport. |
dismissAriaLabel | string | 'Dismiss notification' | Localized accessible label for every dismiss action. |
Accessibility
- Viewport uses aria-live="polite" so new notifications are announced without interrupting users.
- Danger messages use alert semantics; other variants use atomic status semantics.
- Messages persist until dismissed unless the caller explicitly supplies a positive duration.
- Viewport spacing uses the larger of viewportOffset and the active device safe-area inset on each screen edge.
Keyboard behavior
- Dismiss buttons are keyboard reachable.
Testing guidance
- Assert service helpers, ID replacement, timed dismissal, dismiss/clear, rendered roles, message cap, placement, offsets, safe-area classes, and harness dismissal.