Cross-framework Widget for Monitoring
npm install @chainlove/sla-widget**A lightweight, frameworkβagnostic component to display the health status of
your services.** Works with vanilla JS, React, Next.js, or straight from a CDN.
---
``html
type="module"
src="https://cdn.jsdelivr.net/npm/@chainlove/sla-widget/dist/vanilla.mjs"
>
`
- Live demo on CodePen
- Live demo on StackBlitz
---
- π Drop-in integration (Web Component or React)
- π¨ 4 themes: light, dark, highContrast, autoembedded
- πΌοΈ Flexible placement: panel or bannerfull
- π Detail levels: or problemsOnly
- π Auto-refresh (configurable)
- π¬ Custom messages per health state
- β οΈ Graceful degradation on API failure
- π CDN or npm / yarn / pnpm
- π¦ Tiny bundle size
---
`bash`
npm install @chainlove/sla-widgetor
yarn add @chainlove/sla-widgetor
pnpm add @chainlove/sla-widget
`html`
type="module"
src="https://cdn.jsdelivr.net/npm/@chainlove/sla-widget/dist/vanilla.mjs"
>
---
`html`
details="full"
theme="auto"
position="banner"
>
- Live demo on CodePen
- Live demo on StackBlitz
---
`tsx
import { SLAWidget } from '@chainlove/sla-widget/react';
details="full"
theme="auto"
position="banner"
/>;
`
---
`html
`
- Live demo on CodePen
- Live demo on StackBlitz
---
#### Usage:
- React / CoreJS: serviceIds β string[]service-ids
- Web Component (HTML): β comma-separated string
#### Type:
- React/CoreJS β string[] Example: ['0x123...', '0x456...']string
- Web Component β comma-separated Example: "0x123...,0x456..."
#### Description:
List of Service IDs to display.
π You can dynamically update this list:
- React: by updating the serviceIds propelement.setAttribute('service-ids', '...')
- Web Component: by calling
---
#### Usage:
- React / CoreJS: statusEndpoint β stringstatus-endpoint
- Web Component (HTML): β string
#### Default: 'API_URL'
API endpoint URL for fetching service status.
---
#### Usage:
- React / CoreJS: refreshIntervalMs β numberrefresh-interval-ms
- Web Component (HTML): β number
#### Default: false (disabled)
How it works:
- The widget fetches data from API endpoint (statusEndpoint).
Behavior:
- If you set refreshIntervalMs = false (default), the widget fetches datarefreshIntervalMs
once, when the page loads.
- If you set to a value (e.g. 5000 = 5 sec), the widget
will update data at that interval
---
#### Usage:
- React / CoreJS: theme β 'light' | 'dark' | 'highContrast' |'auto'
theme
- Web Component (HTML): β same values
#### Default: 'auto'
Widget theme. π Can be changed dynamically.
---
#### Usage:
- React / CoreJS: position β 'banner' | 'embedded'position
- Web Component (HTML): β same values
#### Default: 'banner'
Widget position on the page:
- position="banner" β widget is displayed as a banner at the top of theposition="embedded"
site.
- β widget is displayed as an inline block (you can place
it anywhere in the page).
---
#### Usage:
- React / CoreJS: details β 'full' | 'problemsOnly'details
- Web Component (HTML): β same values
#### Default: 'problemsOnly'
Controls when the widget is shown:
- details="full" β widget is always visible.details="problemsOnly"
- β widget is shown only if one or more services inservice ids
have Downtime or Latency. It disappears if all services
are in Uptime.
---
#### Usage:
- React / CoreJS: mode β 'simple' | 'dev'mode
- Web Component (HTML): β same values
#### Default: 'simple'
Controls the display mode of the widget:
- mode="simple" β the widget shows a compact banner or embedded block:
- If any service has Downtime (error) or Latency (warning), thecustomMessages
banner displays a custom message (see / custom-messagesok
option below).
- If all service are healthy (), the banner may be hidden (ifdetails='problemsOnly'
) or show a neutral state (if details='full').
Example for customizing messages (for Web Component):
`html`
custom-messages='{"warning":"β οΈ Check this","error":"π¨ Critical issue"}'
Example for customizing messages (for React):
`tsx`
customMessages={{
warning: "β οΈ Check this",
error: "π¨ Critical issue",
}}
/>
- mode="dev" β the widget displays a detailed panel with:
- full list of all service
- current health status for each service
- latency / downtime metrics
- useful for debugging and monitoring purposes.
π Typical usage:
- Use 'simple' for production websites and user-facing pages.'dev'
- Use for internal dashboards, monitoring panels, or while testing.
---
#### Usage:
- React / CoreJS: pinned β 'slide' \| 'fixed'pinned
- Web Component (HTML): β same values
#### Default: 'slide'
Widget pinning behavior:
- 'slide' β widget is placed at the top of the page, **inside the normal page'fixed'
flow**.
When the user scrolls down, the widget will scroll out of view (i.e. it moves
with the page).
- β widget is pinned to the viewport (CSS position: fixed) and
remains always visible, even when the user scrolls the page.
π Use 'fixed' if you want the widget to stay on screen at all times. 'slide'
Use for more lightweight appearance (standard banner behavior at top
of page).
---
#### Usage:
- React / CoreJS: customMessages β { [key in Health]?: string }custom-messages
- Web Component (HTML): β JSON string
#### Default: {}
Custom text to display for each health state. π Works **only in
mode="simple"**.
You can override the default built-in labels with your own text or icons for:
- UP β when all services are healthyLATENCY
- β when one or more services have high latencyDOWN
- β when one or more services are downUNKNOWN
- β when the status of one or more services is unknown
#### Possible keys of Health:
`typescript`
export type Health = 'UP' | 'LATENCY' | 'DOWN' | 'UNKNOWN';
#### Example for Web Component:
`html`
custom-messages='{"UP":"β
All systems operational","LATENCY":"β οΈ Some delays","DOWN":"π¨ Outage detected","UNKNOWN":"β Status unknown"}'
>
#### Example for React:
`tsx``
customMessages={{
UP: "β
All systems operational",
LATENCY: "β οΈ Some delays",
DOWN: "π¨ Outage detected",
UNKNOWN: "β Status unknown",
}}
---
Additionally, when using the widget, you can dynamically adjust settings
(mode, details) by clicking the βοΈ settings button inside the widget.
---
Feel free to open issues, submit pull requests, or suggest improvements!
---
MIT