Componentfeedback0.9 KB gzipZero dependencies
Offline Banner
Offline banner listening to navigator.onLine with reconnecting state.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add offline-bannerOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { OfflineBanner } from "@/components/ui/offline-banner"; <OfflineBanner />Source code
offline-banner.tsx + 1 helperZero 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
| Prop | Type | Description |
|---|---|---|
| className | string | Additional CSS classes applied to the banner container. |