Skip to main content
U.S. Flag

An official website of the United States government

CMS Design System

Idle Timeout

A component that counts down to the end of a session (behind the scenes) and shows a warning message after a set amount of time of inactivity.

Examples

Loading

Code

React

React Properties Documentation
NameTypeDefaultDescription
closeButtonTextstringCloseThe text for the dialog's 'close' button
continueSessionTextstringContinue sessionThe text for the 'continue session' button in warning dialog.
headingstringAre you still there?The heading text for the warning dialog.
endSessionButtonTextstringLogoutThe text for the button that ends the session in warning dialog.
endSessionUrlstring/logoutThe URL to direct to when the user intentionally ends the session.
formatMessage(timeTilTimeout: number) => ReactNode(timeTilTimeout: number): React.ReactNode => { const unitOfTime = timeTilTimeout === 1 ? 'minute' : 'minutes'; return ( <p> You&apos;ve been inactive for a while. <br /> Your session will end in{' '} <strong> {timeTilTimeout} {unitOfTime} </strong> . <br /> <br /> Select &quot;Continue session&quot; below if you want more time. </p> ); }A formatting function that returns the string to be used in the warning modal. The formatting function is provided the timeTilTimeout (in minutes).
onSessionContinue(...args: any[]) => anyOptional function that is called when the user chooses to keep the session alive. This function is called by the 'continue session' button or the 'close' button. The IdleTimeout component will reset the countdown internally.
onSessionForcedEnd(...args: any[]) => anyOptional function that is called when the session is manually ended by user. If not provided, the behavior of onTimeout will be used.
onTimeoutrequired(...args: any[]) => anyFunction that is called when the timeout countdown reaches zero.
showSessionEndButtonbooleanfalseDescribes if the button to manually end session should be shown in the warning dialog.
timeToTimeoutrequirednumberDefines the amount of minutes of idle activity until the session is timed out
timeToWarningrequirednumberDefines the amount of minutes of idle activity that will trigger the warning message.

Customization

The following CSS variables can be overridden to customize Dialog components:

CSS variables for dialog
VariableDefault Core Theme Value
--dialog__background-colorhex value: #ffffff--color-white
--dialog__padding32px
--dialog-overlay__background-colorhex value: #00000080--color-transparent-black-alpha50

Guidance

When to use

  • Use the IdleTimeout for authenticated sessions to force logout after a set amount of time on inactivity

Component maturity

For more information about how we tested and validated our work for each checklist item, read our component maturity documentation.

Accessibility

  • Color

    Meets AA color contrast standards for accessibility and color blindness.
    Complete
  • Forced Colors Mode (FCM)

    While using FCM the components text is legible and improves readability.
    Complete
  • WCAG 2.1 Level AA Conformance

    All Axe checks for WCAG AA compliance have passed.
    Complete
  • Screen readers

    VoiceOver, NVDA, and JAWS screen readers provide concise communication and interaction.
    Complete
  • Keyboard navigation

    Component is fully navigable with a keyboard.
    Complete

Code

  • Storybook

    Component has stories to cover all defined props.
    Complete
  • Responsive

    Component designed to work in all responsive breakpoints.
    Complete
  • Spanish translations

    Includes Spanish translations for default text content.
    Complete

Tokens

  • Code

    Tokens implemented in code.
    Complete
  • Design

    Tokens implemented in the Sketch.
    Complete