Skip to content

OfflineNotice

Appears when the browser loses the connection and says what still works; goes away by itself when the connection comes back.

import { OfflineNotice } from '@sypnia/ui/react'

On this page
  1. No connection
  2. When to use it
  3. For everyone
  4. Props

No connection

Press the button to bring it back.

No connection. What you see stays here; changes are saved when the connection comes back.
Code
import { useState } from 'react';
import { Button, OfflineNotice } from '@sypnia/ui/react';

// It follows the browser by itself; here a button pretends the connection is lost.
export default function Lost() {
  const [offline, setOffline] = useState(true);
  return (
    <div className="sy-stack">
      <OfflineNotice offline={offline} />
      <Button size="sm" onClick={() => setOffline(!offline)}>{offline ? 'Bring the connection back' : 'Lose the connection'}</Button>
    </div>
  );
}

When to use it

Use it when

  • Once, at the top of the content of apps that keep working offline for a while.

Do not use it when

  • Errors of one request: say them where they happened.

For everyone

  • It is a polite status: it is read when it appears and when it goes.

Props

OfflineNoticeTypeDefault
offline boolean
  1. No connection
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms