Renders a small notification bar at the very top of the page when the browser reports no network connection. It informs users that their connection to the site has been lost, that they are viewing a cached, offline version of the content, and that some features may be unavailable until they reconnect.
It complements the service worker offline support: while the service worker serves previously fetched content, this plugin keeps users clearly aware of the offline state.
To load this plugin, add it to the extras block in your
config.php or theme
settings.php:
'extras' => [
// ...
'offline-notification' => [],
// ...
],
Or, on the client only, via CMS.loadExtra() in the theme:
<script>
CMS.loadExtra('offline-notification');
</script>
This plugin is client-side only and has no server component.
| Parameter | Required | Example | Description | Default |
|---|---|---|---|---|
styles |
no | false |
Load the bundled default stylesheet (see below). | true |
title |
no | 'Offline' |
Bold heading shown inside the notification. | 'You\u2019re offline' |
message |
no | '...' |
Body text explaining the offline state. | see default below |
showIcon |
no | false |
Show the leading warning glyph. | true |
Defaults:
{
styles: true,
title: "You are offline!",
message: "Connection to the server was lost. You are viewing an offline " +
"version of this site and some features may be unavailable until you " +
"reconnect.",
showIcon: true,
}
The plugin ships default styling (amber warning bar, with a dark-mode fallback)
loaded automatically when styles is true. These defaults are intentionally
theme-agnostic. To customize the look, add rules targeting the class names
below to your theme stylesheet.
/** <editor-fold desc="Offline Notification"> **/
.offline-notification {
background-color: #e74c3c; /* any warning/error color */
color: #ffffff;
padding: 0.5em 1.5em;
font-size: 1em;
}
.offline-notification__icon {
font-size: 1.25em;
}
.offline-notification__title {
font-weight: 700;
margin: 0;
}
.offline-notification__message {
margin: 0;
font-weight: 400;
}
/*
* Override the dark-mode default:
*/
@media (prefers-color-scheme: dark) {
.offline-notification {
background-color: #7f1d1d;
color: #fde6e6;
}
}
/** </editor-fold desc="Offline Notification"> **/
To supply your own stylesheet entirely, set 'styles' => false and load your
own CSS targeting those same class names.
online and offline events and reads
navigator.onLine to determine connectivity.<body>;
when the connection returns it is removed. The bar persists across in-page
(hash/history) route changes, since it lives on <body>, not inside the CMS
content container.The notification is marked with role="alert" and aria-live="assertive", so
screen readers announce it when the connection is lost. The decorative warning
icon is hidden from assistive technology via aria-hidden.