Skip to content

Toast

Toasts are transient notifications. Place one <ax-toast-outlet> in the app shell, then call ToastService.show(...) from anywhere. The outlet stacks active toasts, pauses auto-dismiss while hovered or focused, and exposes a dismiss control when configured.

import { ToastService, AxToastOutletComponent } from '@axisui-ng/feedback';
<!-- once, near the app root -->
<ax-toast-outlet position="bottom-end" />
import { inject } from '@angular/core';
import { ToastService } from '@axisui-ng/feedback';
export class SaveButton {
private readonly toast = inject(ToastService);
save() {
this.toast.show({
title: 'Saved',
description: 'Your changes are live.',
variant: 'success',
duration: 4000,
});
}
}
OptionValuesDefaultNotes
position (ax-toast-outlet)'top-start' | 'top-center' | 'top-end' | 'bottom-start' | 'bottom-center' | 'bottom-end''bottom-end'Where toasts stack.
variant (ToastConfig)'default' | 'success' | 'warning' | 'destructive''default'Surface tint on each toast.
this.toast.show({ title: 'Done', variant: 'success' });
this.toast.show({ title: 'Check this', variant: 'warning' });
this.toast.show({ title: 'Failed', variant: 'destructive', duration: 0 });
InputTypeDefaultNotes
position'top-start' | 'top-center' | 'top-end' | 'bottom-start' | 'bottom-center' | 'bottom-end''bottom-end'Fixed stack anchor (logical start/end).
MethodSignatureNotes
showshow(config: ToastConfig): ToastRefEnqueues a toast; returns { dismiss() } for imperative close.
dismissdismiss(id: number): voidRemoves a toast by id (also used by the outlet close button).
pausepause(): voidPauses auto-dismiss timers (outlet calls this on hover/focus).
resumeresume(): voidResumes timers with remaining time.
toastsReadonlySignal<Toast[]>Read-only view of active toasts.
FieldTypeDefaultNotes
titlestringRequired headline.
descriptionstringOptional supporting line.
variant'default' | 'success' | 'warning' | 'destructive''default'Visual style.
durationnumber5000Auto-dismiss ms; 0 = sticky.
dismissiblebooleantrueShows the close button on the toast.

The outlet is a landmark region (role="region", aria-label="Notifications"). Each toast sets role + aria-live by severity: warning / destructivealert / assertive; default / successstatus / polite. Auto-dismiss pauses while the outlet is hovered or focused (WCAG 2.2.1). Sticky toasts (duration: 0) should keep dismissible enabled so users can close them.

Interactive examples live in Storybook under Feedback / Toast. Run pnpm storybook to explore them.