Componentfeedback0.9 KB gzipZero dependencies

Offline Banner

Offline banner listening to navigator.onLine with reconnecting state.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add offline-banner

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { OfflineBanner } from "@/components/ui/offline-banner"; <OfflineBanner />

Source code

offline-banner.tsx + 1 helper

Zero third-party dependencies (2 local files shown in tabs below).

tsxoffline-banner.tsx72 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; function subscribeOnline(onChange: () => void): () => void {  if (typeof window === "undefined") return () => {};  window.addEventListener("offline", onChange);  window.addEventListener("online", onChange);  return () => {    window.removeEventListener("offline", onChange);    window.removeEventListener("online", onChange);  };} function getOnlineSnapshot(): boolean {  return typeof navigator !== "undefined" ? navigator.onLine : true;}

Props

PropTypeDescription
classNamestringAdditional CSS classes applied to the banner container.