ReactJS library to output a text when browser is offline (real offline as no wifi or throttled offline).
By default it renders green 'online' when online and red 'offline', when offline. But it is possible to override styles, classes and the messages. See "Configuration examples" lower.
yarn add react-you-are-offline
// or
npm i react-you-are-offline
import { YouAreOffline } from 'react-you-are-offline';
class MyComponent extends React.Component {
render(){
return (
<YouAreOffline />
)
}
}
export default MyComponent;
let message = 'You are online';
let customStyle = { color: 'limegreen', backgroundColor: '#333333' };
let customClass = 'alert alert-success'
<YouAreOffline whenOnline={customMessage} onlineStyle={customStyle} onlineClass={customClass}/>
let message = 'You are OFFLINE!';
let customStyle = { color: 'orange', backgroundColor: '#333333' };
let customClass = 'alert alert-danger'
<YouAreOffline whenOffline={customMessage} offlineStyle={customStyle} offlineClass={customClass}/>
This software is released under ISC licence