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.
<IdleTimeout>
Code snippet
Props
Name | Type | Default | Description |
---|---|---|---|
closeButtonText | string | 'Close' | The text for the dialog's 'close' button |
continueSessionText | string | 'Continue session' | The text for the 'continue session' button in warning dialog. |
heading | string | 'Are you still there?' | The heading text for the warning dialog. |
endSessionButtonText | string | 'Logout' | The text for the button that ends the session in warning dialog. |
endSessionUrl | string | '/logout' | The URL to direct to when the user intentionally ends the session. |
formatMessage | (timeTilTimeout: number) => string | React.ReactNode | (timeTilTimeout: number): React.ReactNode => {
const unitOfTime = timeTilTimeout === 1 ? 'minute' : 'minutes';
return (
<p>
You've been inactive for a while.
<br />
Your session will end in{' '}
<strong>
{timeTilTimeout} {unitOfTime}
</strong>
.
<br />
<br />
Select "Continue session" 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[]) => any | Optional 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[]) => any | Optional function that is called when the session is manually ended by user.
If not provided, the behavior of | |
onTimeout required | (...args: any[]) => any | Function that is called when the timeout countdown reaches zero. | |
showSessionEndButton | boolean | false | Describes if the button to manually end session should be shown in the warning dialog. |
timeToTimeout required | number | Defines the amount of minutes of idle activity until the session is timed out | |
timeToWarning required | number | Defines the amount of minutes of idle activity that will trigger the warning message. |
Guidance
When to use
- Use the IdleTimeout for authenticated sessions to force logout after a set amount of time on inactivity
Customization
The following Sass variables can be overridden to customize Dialog components: