# Offline Plug

A connection status pill with a shaded plug and power strip. When the network drops, the plug is yanked out in a burst of sparks, falls to the floor and rocks to rest on its simulated cable, then keeps trying to get back in. Drag it into the socket to retry: it stays in with a green light when the connection is back, or gets thrown out again.

- Page and source: https://uibrik.com/components/offline-plug
- Install (Pro, needs a license key, see https://uibrik.com/docs/pro): `npx shadcn@latest add @uibrik-pro/offline-plug`
- Packages: none beyond React
- Import: `import { OfflinePlug } from "@/components/uibrik/offline-plug/offline-plug"`

Where to use the Offline Plug React component:

- **Offline-first apps**: Users see the moment the connection drops and the moment it comes back. Pairs with [Toast](https://uibrik.com/components/toast).
- **Editors and dashboards**: Fading the page while offline explains why live data has stopped moving. Pairs with [Status Dashboard](https://uibrik.com/components/status-dashboard).
- **Mobile web**: Flaky connections on the move get a calm, glanceable state instead of failed requests.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| offlineLabel | `string` | `"Offline"` |  |
| onlineLabel | `string` | `"Online"` |  |
| hideAfter | `number` | `0` | How long the pill stays once back online. 0 keeps it there all the time. |
| attemptEvery | `number` | `4` | Seconds between the plug's own attempts to get back in. 0 to stop. |
| haptics | `boolean` | `false` | Buzz the phone on unplug and plug-in, where supported. |
| sparkColor | `string` | `"#f59e0b"` | Spark when the plug pulls out. |
| successColor | `string` | `"#22c55e"` | Charging light on the plug, lit while connected. |
| online | `boolean` |  | Controlled connection state. Leave out to follow the browser's online and offline events. |
| position | `"top" \| "bottom"` | `"top"` | Where the pill sits over its content. |
| dim | `boolean` | `true` | Fade the wrapped content while offline. |
| retry | `boolean` | `true` | Let the user push the plug back in, by drag or Enter, to try reconnecting. |
| onRetry | `() => boolean \| void \| Promise<boolean \| void>` |  | Called when the plug is pushed home. Resolve true if back online; false throws it back out. |
| fixed | `boolean` | `false` | Pin the pill to the viewport instead of the wrapper. |
| onChange | `(online: boolean) => void` |  | Called when the connection drops or returns. |
| children | `ReactNode` |  | The page or panel the pill floats over. |
| className | `string` |  | Classes for the wrapper. |
