Skip to content
Product block

Offline With Queued Changes

Leads with what still works — three edits saved on this device — instead of with the failure. The retry backoff counts down in the open, and the three things that genuinely cannot work offline are named rather than discovered.

173 lineslucide-reactAdded 27 Aug 2026
  • offline
  • network
  • retry
  • queue
  • resilience

What's included

  • components/offline-state-banner.tsx
  • Needs lucide-react

Works with

  • React
  • Next.js
  • Tailwind CSS
  • TypeScript

npx hoverlab add offline-state-banner

Or over MCP, from your editor's agent — no account needed.

License

Free to read, copy and install, for personal and non-commercial projects. Shipping it in client work or a paid product needs Pro ($79 once). The source lands in your repo and stops being ours — no attribution, nothing to upgrade.

Was this useful?

Start a page with this section — add more, order them, and leave with the page source.

Preview

3 changes are saved on this device

You are offline. Keep working — edits are written locally and sent automatically the moment the connection is back. Nothing is lost by closing this tab, though it will not send until you open it again.

Trying again in 8s · attempt 2

Not available until you reconnect

  • Searching across the workspace
  • Inviting people
  • Publishing or sharing a link

Rendered live in your current theme — this is the same component whose source is below, not a screenshot of it.

Source

components/offline-state-banner.tsx
'use client'

/**
 * <OfflineStateBanner> — the connection is gone; here is what still works.
 *
 * Empty & Error States had the empty state, the retry, the 404, the
 * skeleton and the 403. All five are answers the *server* gave. Losing
 * the network is the one failure where there is no answer at all, and it
 * is the most common one on a train, in a lift, or on hotel wifi.
 *
 * THE ONE THING THIS GETS RIGHT THAT MOST DO NOT
 *
 * The banner leads with what is still safe to do, not with the failure.
 * "You are offline" tells someone what they already suspect; "your last
 * three edits are saved on this device and will send when you reconnect"
 * is the sentence that decides whether they keep typing or close the tab
 * and lose the work. The unsent count is the headline number.
 *
 * THE RETRY IS VISIBLY BACKING OFF
 *
 * A spinner that has been going for four minutes teaches people that the
 * app is broken. Showing the interval — "trying again in 8s", then 16, then
 * 30 — is honest about exponential backoff and makes "Retry now" a
 * meaningful button rather than a placebo, because it is the only thing
 * that skips the wait.
 *
 * WHAT WILL NOT WORK IS LISTED
 *
 * Offline is not a single state: local edits queue, but anything needing
 * the server — search across the workspace, inviting somebody, publishing
 * — cannot. Naming those three stops the user discovering them one
 * failed click at a time.
 *
 * ACCESSIBILITY: `role="status"` with `aria-live="polite"`, not `alert` —
 * losing wifi is not an emergency and an assertive region interrupts
 * whatever the user is typing, which is precisely the thing this banner
 * is reassuring them they may continue to do.
 */

import * as React from 'react'
import { CloudOff, RefreshCw, WifiOff } from 'lucide-react'

export interface OfflineStateBannerProps {
  /** Changes saved locally and waiting to send. */
  queuedChanges?: number
  /** What is unavailable until the connection returns. */
  unavailable?: string[]
  className?: string
}

const DEFAULT_UNAVAILABLE = [
  'Searching across the workspace',
  'Inviting people',
  'Publishing or sharing a link',
]

/** Backoff intervals, in seconds. Shown, not just used. */
const BACKOFF = [8, 16, 30, 60]

export function OfflineStateBanner({
  queuedChanges = 3,
  unavailable = DEFAULT_UNAVAILABLE,
  className = '',
}: OfflineStateBannerProps) {
  const [attempt, setAttempt] = React.useState(0)
  const [seconds, setSeconds] = React.useState(BACKOFF[0]!)
  const [trying, setTrying] = React.useState(false)

  /*
   * Declared before the effects that call it, and memoised.
   *
   * Both are the lint rule's doing rather than taste, and both are right:
   * a function hoisted past the effect that depends on it is invisible to
   * dependency checking, and an un-memoised one would restart the
   * countdown on every render — which is a timer that never reaches zero.
   */
  const retry = React.useCallback(() => {
    setTrying(true)
    window.setTimeout(() => {
      setAttempt((a) => {
        const next = Math.min(a + 1, BACKOFF.length - 1)
        setSeconds(BACKOFF[next]!)
        return next
      })
      setTrying(false)
    }, 900)
  }, [])

  /* The visible countdown. A wait nobody can see reads as a hang. */
  React.useEffect(() => {
    if (trying || seconds <= 0) return
    const timer = window.setTimeout(() => setSeconds((s) => s - 1), 1000)
    return () => window.clearTimeout(timer)
  }, [seconds, trying])

  React.useEffect(() => {
    if (trying || seconds > 0) return
    // Firing when the countdown reaches zero is the whole intent — this is
    // the automatic attempt the visible timer has been counting down to.
    retry()
  }, [seconds, trying, retry])

  return (
    <section className={`mx-auto w-full max-w-2xl px-4 py-16 sm:px-6 ${className}`}>
      <div
        role="status"
        aria-live="polite"
        className="overflow-hidden rounded-2xl border border-amber-500/40 bg-amber-500/5"
      >
        <div className="flex flex-wrap items-start gap-3 p-5">
          <span className="mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-amber-500/15 text-amber-700 dark:text-amber-400">
            <WifiOff aria-hidden className="h-4.5 w-4.5" />
          </span>

          <div className="min-w-0 flex-1">
            {/* Reassurance first. The failure is the subheading. */}
            <h2 className="text-base font-semibold text-foreground">
              {queuedChanges === 0
                ? 'Everything you have done is saved on this device'
                : `${queuedChanges} ${
                    queuedChanges === 1 ? 'change is' : 'changes are'
                  } saved on this device`}
            </h2>
            <p className="mt-1 text-sm leading-relaxed text-muted-foreground">
              You are offline. Keep working — edits are written locally and sent
              automatically the moment the connection is back. Nothing is lost by
              closing this tab, though it will not send until you open it again.
            </p>

            <div className="mt-3 flex flex-wrap items-center gap-2">
              <button
                type="button"
                onClick={retry}
                disabled={trying}
                className="inline-flex h-8 items-center gap-1.5 rounded-lg border border-border bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted disabled:cursor-not-allowed disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
              >
                <RefreshCw
                  aria-hidden
                  className={`h-3.5 w-3.5 ${trying ? 'motion-safe:animate-spin' : ''}`}
                />
                {trying ? 'Trying' : 'Retry now'}
              </button>

              {/* The interval, in the open. */}
              <span className="text-xs tabular-nums text-muted-foreground">
                {trying
                  ? 'Reaching the server…'
                  : `Trying again in ${seconds}s · attempt ${attempt + 2}`}
              </span>
            </div>
          </div>
        </div>

        <div className="border-t border-amber-500/30 bg-background/40 px-5 py-3">
          <h3 className="flex items-center gap-1.5 text-xs font-medium text-foreground">
            <CloudOff aria-hidden className="h-3.5 w-3.5" />
            Not available until you reconnect
          </h3>
          {/* Named, so they are not discovered one failed click at a time. */}
          <ul className="mt-1.5 space-y-1 text-xs text-muted-foreground">
            {unavailable.map((item) => (
              <li key={item} className="flex items-start gap-1.5">
                <span aria-hidden className="mt-1.5 h-1 w-1 shrink-0 rounded-full bg-muted-foreground border border-transparent" />
                {item}
              </li>
            ))}
          </ul>
        </div>
      </div>
    </section>
  )
}

Before you paste

  • Styling is Tailwind utility classes on semantic tokens (bg-card, text-muted-foreground) — it inherits your theme instead of overriding it.
  • Install: npm i lucide-react
  • Every prop has a default, so it renders standalone before you wire it up.

Where it goes

Drop it at components/offline-state-banner.tsx and import it where you need the section:

import { OfflineStateBanner } from '@/components/offline-state-banner'

Customize

1 of this block’s props are simple enough to drive from here. Change them and the block below re-renders — it is the same component whose source is above, not a mock of it. Everything else it accepts is in the table underneath.

Props

Read out of the component’s own type and signature, so this cannot drift from the source below. Every prop has a default — the component renders standalone before you pass it anything.

PropTypeDefault
queuedChangesChanges saved locally and waiting to send.number3
unavailableWhat is unavailable until the connection returns.string[]DEFAULT_UNAVAILABLE
classNamestring''

Not using React?

The same block rendered once to markup, wrapped as a file your framework compiles. Tailwind classes are framework-agnostic, so the design transfers intact — the behaviour does not.

This block is interactive. The markup below is its initial state with the event handlers stripped — you will need to re-wire the behaviour in your framework.

offline-state-banner.html
<!--
  Offline With Queued Changes — markup from the Hoverlab catalog.

  This is the block rendered once to HTML and wrapped as a component
  file. It is not a port of the React source: the Tailwind classes carry
  the design, which is the part that took the work, and they are the same
  in every framework.

  This block is interactive in React and the handlers are NOT here.
  Buttons, toggles and menus render in their initial state and do
  nothing until you wire them up.
-->
<section class="mx-auto w-full max-w-2xl px-4 py-16 sm:px-6 ">
  <div role="status" aria-live="polite" class="overflow-hidden rounded-2xl border border-amber-500/40 bg-amber-500/5">
    <div class="flex flex-wrap items-start gap-3 p-5">
      <span class="mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-amber-500/15 text-amber-700 dark:text-amber-400">
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-wifi-off h-4.5 w-4.5" aria-hidden="true">
          <path d="M12 20h.01"></path>
          <path d="M8.5 16.429a5 5 0 0 1 7 0"></path>
          <path d="M5 12.859a10 10 0 0 1 5.17-2.69"></path>
          <path d="M19 12.859a10 10 0 0 0-2.007-1.523"></path>
          <path d="M2 8.82a15 15 0 0 1 4.177-2.643"></path>
          <path d="M22 8.82a15 15 0 0 0-11.288-3.764"></path>
          <path d="m2 2 20 20"></path>
        </svg>
      </span>
      <div class="min-w-0 flex-1">
        <h2 class="text-base font-semibold text-foreground">3 changes are saved on this device</h2>
        <p class="mt-1 text-sm leading-relaxed text-muted-foreground">You are offline. Keep working — edits are written locally and sent automatically the moment the connection is back. Nothing is lost by closing this tab, though it will not send until you open it again.</p>
        <div class="mt-3 flex flex-wrap items-center gap-2">
          <button type="button" class="inline-flex h-8 items-center gap-1.5 rounded-lg border border-border bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted disabled:cursor-not-allowed disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-refresh-cw h-3.5 w-3.5" aria-hidden="true"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"></path><path d="M21 3v5h-5"></path><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"></path><path d="M8 16H3v5"></path></svg>Retry now</button>
          <span class="text-xs tabular-nums text-muted-foreground">Trying again in 8s · attempt 2</span>
        </div>
      </div>
    </div>
    <div class="border-t border-amber-500/30 bg-background/40 px-5 py-3">
      <h3 class="flex items-center gap-1.5 text-xs font-medium text-foreground"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-cloud-off h-3.5 w-3.5" aria-hidden="true"><path d="m2 2 20 20"></path><path d="M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193"></path><path d="M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07"></path></svg>Not available until you reconnect</h3>
      <ul class="mt-1.5 space-y-1 text-xs text-muted-foreground">
        <li class="flex items-start gap-1.5"><span aria-hidden="true" class="mt-1.5 h-1 w-1 shrink-0 rounded-full bg-muted-foreground border border-transparent"></span>Searching across the workspace</li>
        <li class="flex items-start gap-1.5"><span aria-hidden="true" class="mt-1.5 h-1 w-1 shrink-0 rounded-full bg-muted-foreground border border-transparent"></span>Inviting people</li>
        <li class="flex items-start gap-1.5"><span aria-hidden="true" class="mt-1.5 h-1 w-1 shrink-0 rounded-full bg-muted-foreground border border-transparent"></span>Publishing or sharing a link</li>
      </ul>
    </div>
  </div>
</section>
  • This is rendered HTML, not a translation of the React source. The Tailwind classes carry the design and work in any framework.
  • It is one frame: the component in its initial state, with no props applied beyond the defaults.
  • This block is interactive in React — toggles, menus or form state. None of that survives here; the markup is the closed/default state and the handlers are gone. Re-wire them in your own framework.
  • Requires Tailwind, and the design tokens the classes reference (bg-card, text-muted-foreground, and so on). The template ZIPs ship a globals.css that defines them.

What each framework gets across the whole catalog — effects convert properly; this rung is markup.

For AI

The component, its props, the design tokens it expects and the command that installs it — as one prompt. Paste it into Claude, Cursor, v0 or ChatGPT and what they build around it will match the rest of the catalog instead of inventing its own system.

See the prompt

Used in these pages

Want the whole screen instead of this one section? Open a page and copy it entire.

7 more blocks in Empty & Error States

All of them free to read, copy and install — no account, no locked tiles, no watermarked preview. The whole catalog is open, and so are the API and the CLI.

Browse Empty & Error States

Shipping one commercially

Copying the code is free. Putting it in client work or a paid product is what Pro is for — the licence, not the access.

  • A commercial licence for everything in the catalog
  • Unlimited bundle exports, in Vue, Svelte and Tailwind
  • One payment — no subscription, nothing to renew
Pro — $79 once

More Empty & Error States blocks

View category
Open the full page for this block

Empty State With Illustration

Two variants — nothing created yet, versus filters excluded everything — because offering "create your first" to a bad filter is the classic bug.

Empty & Error States131 lines1 dep
Open the full page for this block

Error State With Retry

Failed-to-load panel with a visible retry, a copyable error reference and the stack tucked behind a disclosure.

Empty & Error States131 lines1 dep
Open the full page for this block

404 With Search & Suggestions

A 404 that helps: a real GET search form that works without JavaScript, likely destinations, and home as the fallback rather than the headline.

Empty & Error States146 lines1 dep
Open the full page for this block

Shimmer Skeleton List

Loading placeholders with varied row widths and a sweep that is motion-safe only, falling back to a flat tint under reduced motion.

Empty & Error States88 linesNo deps
Open the full page for this block

Permission Denied (403)

The state where the page exists and the account is not on the list: names who can grant access, sends the request, and leaks nothing about what is inside.

Empty & Error States175 lines1 dep
Open the full page for this block

Empty Because of Filters

The empty state for a list emptied by its own filters: every active filter shown as a removable chip ordered by how many results it would restore, with clear-all deliberately second.

Empty & Error States186 lines1 dep
Open the full page for this block

Scheduled Maintenance Window

Planned downtime with a live countdown, an end time in the reader’s timezone, what still works — and a different sentence once the window overruns rather than a negative timer.

Empty & Error States228 lines1 dep