Skip to content

Session Warning Dialog for Angular

AngularAuthentication UI

Alert dialog (built on Dialog) that counts down to a session deadline (an Instant) and offers “Stay signed in” and “Sign out” (WCAG 2.2.1 Timing Adjustable). Remaining time is a duration from the deadline to the current clock, so it is timezone independent. Announcements are throttled to thresholds. It pauses, extends, and ends nothing on its own: it emits aui-extend, aui-sign-out, and aui-expire.

  • Live countdownCounts down to the session deadline, recomputed from the clock on every tick.
  • Opens on timeOpens automatically a set time before expiry, at least 20 seconds ahead.
  • Extend or sign outSeparate events for staying signed in, signing out, and expiry.
  • Measured announcementsScreen readers hear the remaining time at intervals, not every second.

Behavior, design tokens, and limitations are described on the Session Warning Dialog page; this page covers the Angular API.

import { Component, signal } from '@angular/core';
import { instant, type Instant } from '@absoluteui/core';
import { AuiSessionWarningDialog } from '@absoluteui/angular/session-warning-dialog';
import { AuiButton } from '@absoluteui/angular/button';
@Component({
selector: 'app-session',
imports: [AuiSessionWarningDialog, AuiButton],
template: `
<aui-session-warning-dialog [open]="warn()" [expiresAt]="expiresAt()"
(extended)="extend()" (signedOut)="signOut()" (closed)="warn.set(false)">
<p>Unsaved changes are kept.</p>
</aui-session-warning-dialog>
<button type="button" auiButton (click)="warn.set(true)">Show the warning</button>
`,
})
export class SessionComponent {
readonly warn = signal(false);
readonly expiresAt = signal<Instant>(instant(Date.now() + 15 * 60_000));
extend(): void {
this.expiresAt.set(instant(Date.now() + 15 * 60_000));
}
signOut(): void {
location.assign('/sign-out');
}
}
Terminal window
npm install @absoluteui/angular @absoluteui/components @absoluteui/core @absoluteui/theme

Setup with provideAbsoluteUI() is covered in Getting started. Styles are included with the component.

import { AuiSessionWarningDialog } from '@absoluteui/angular/session-warning-dialog';

Defaults for every instance: provideAbsoluteUIConfig({ components: { sessionWarningDialog: { ... } } }) (see Configuration).

Class AuiSessionWarningDialog; template reference #ref="auiSessionWarningDialog".

AbsoluteUI Session Warning Dialog; projected content is added below the countdown: <aui-session-warning-dialog [expiresAt]="deadline()" [(open)]="warn" (extended)="extend()">...</aui-session-warning-dialog>. With warnBefore it opens itself; open follows it either way.

Server rendering: Renders in the browser only; on the server the element stays empty.

Input Type Default Description
expiresAt Instant Required. When the session ends.
warnBefore Duration Open automatically this long before expiresAt (at least 20 s).
title string Default: localized “Your session is about to expire”.
message string Default: localized inactivity message.
extendLabel string Default: localized “Stay signed in”.
signOutLabel string Default: localized “Sign out”.
expiredTitle string Default: localized “Your session has expired”.
expiredMessage string Default: localized “You have been signed out. Sign in again to continue.”
signInLabel string The single action after expiry. Default: localized “Sign in again”.
announceInterval number '60' Announce the remaining time each time it crosses a multiple of this many seconds (15..3600), and at 60, 30, and 10 seconds.
escapeExtends boolean true Escape means “Stay signed in”; when false, Escape does nothing.
locale string 'en-US' Message and unit-formatting locale.
Model Type Change output Description
[(open)] boolean (openChange) Whether the warning dialog is shown: [(open)]. Closing by Escape, the close button, or an action sets it to false.
Output Payload Description
(opened) null The dialog opened (from Dialog). Re-emits aui-open.
(closed) DialogCloseDetail The dialog closed (from Dialog). Re-emits aui-close.
(extended) SessionWarningExtendDetail The user chose to stay signed in: extend the session, then call update({ expiresAt }). Re-emits aui-extend.
(signedOut) SessionWarningSignOutDetail The user chose to sign out, or acknowledged expiry (“Sign in again”). Re-emits aui-sign-out.
(expired) null The deadline passed (once per deadline, open or closed). Re-emits aui-expire.

Pattern: WAI-ARIA alertdialog (native modal <dialog>) named by its title and described by the message and countdown.

The Angular component renders the framework-neutral component, so its keyboard support, roles, WCAG 2.2 criteria, budgets, and import cost apply unchanged: see Session Warning Dialog: Accessibility and performance.