Show a notification
const save = async () => {
// await api.save();
TemporaryNotification.show("Your application has been saved.", {
type: "success"
});
};<GoabTemporaryNotificationCtrl />
<GoabxButton type="secondary" onClick={save}>Save</GoabxButton>async save(): Promise<void> {
// await this.api.save();
TemporaryNotification.show("Your application has been saved.", {
type: "success"
});
}<goab-temporary-notification-ctrl></goab-temporary-notification-ctrl>
<goabx-button type="secondary" (onClick)="save()">Save</goabx-button>document.getElementById('save-btn').addEventListener('_click', () => {
// await api.save();
document.body.dispatchEvent(new CustomEvent("msg", {
composed: true,
bubbles: true,
detail: {
action: "goa:temp-notification",
data: {
message: "Your application has been saved.",
type: "success",
uuid: crypto.randomUUID(),
duration: "short"
}
}
}));
});<goa-temp-notification-ctrl></goa-temp-notification-ctrl>
<goa-button version="2" id="save-btn" type="secondary">Save</goa-button>Show a temporary notification to confirm an action was completed successfully.
When to use
Use this pattern when:
- Confirming that a save operation completed successfully
- Providing immediate feedback after a user action
- The notification should automatically dismiss after a few seconds
- Users need non-intrusive confirmation of their action
Considerations
- Use the
typeoption to indicate the nature of the notification (success, information, etc.) - Import
TemporaryNotificationfrom@abgov/ui-components-common - Include a
<GoabTemporaryNotificationCtrl />component in your app to render notifications - Keep notification messages concise and action-oriented
- Notifications auto-dismiss after a default duration