Uptime status bar — a row of colored segments indicating service health over time.
Inspired by Instastatus and Statuspage.io. Each segment represents a time period (hour, day, or week) with a color conveying its health status:
| Status | Color | Tailwind class |
|---|---|---|
:up | Green | bg-green-500 |
:down | Red | bg-red-500 |
:degraded | Yellow | bg-yellow-500 |
The overall uptime percentage is computed server-side from the segment list.
Native browser tooltips (title attribute) reveal date/status details on hover —
no JavaScript required.
Examples
<%!-- Static 90-day bar --%>
<.uptime_bar segments={@daily_statuses} />
<%!-- Custom period --%>
<.uptime_bar segments={@hourly_statuses} days={7} />
<%!-- With labels (shown as native tooltip) --%>
<.uptime_bar segments={
Enum.map(@log, fn entry ->
%{status: entry.status, label: Date.to_iso8601(entry.date)}
end)
} />
Summary
Functions
Renders a horizontal uptime bar with colored segments and an uptime percentage.
Functions
Renders a horizontal uptime bar with colored segments and an uptime percentage.
Example
<.uptime_bar segments={@statuses} days={90} />Attributes
segments(:list) - List of segment maps. Each map must have:status(:up | :down | :degraded). Optional:labelstring is shown as a native browser tooltip on hover. Defaults to[].days(:integer) - Number of days represented (used for the '90 days ago' label). Default:90. Defaults to90.class(:string) - Additional CSS classes for the root element. Defaults tonil.- Global attributes are accepted. HTML attributes forwarded to the root
<div>element.