仪表小组件
在固定最小值和最大值之间的表盘上显示一个数值。最适合 SLO、错误预算、温度和容量。
The gauge template draws a value on an arc between two bounds you choose. It answers
"how close to the limit is this?", which a bare number cannot: 2.4 means nothing until you know the
ceiling is 5.
Fields
| Field | Type | Notes |
|---|---|---|
template | string | Required. Must be "gauge" |
value | float | Required. Must be finite and fall within min_value – max_value; outside that range the request is rejected with 422 |
min_value | float | Required. Start of the arc. Must be strictly less than max_value |
max_value | float | Required. End of the arc |
unit | string | Appended to the value and to the MIN / MAX end labels. Max 32 characters |
trend | string | up / down / flat. Accepted by the server; the current iOS gauge does not draw an arrow, so treat it as forward-looking metadata rather than something users will see |
label, subtitle, icon, accent_color, background_color, text_color | string | Shared content fields — see the API reference |
Example: error rate against an SLO
{
"content": {
"template": "gauge",
"value": 2.4,
"min_value": 0,
"max_value": 5,
"unit": "%",
"label": "Errors",
"subtitle": "api-gateway · last 5m · SLO 1.0%",
"icon": "chart.line.uptrend.xyaxis",
"accent_color": "red"
}
}Behavior
Pick bounds once and keep them fixed. The arc's meaning comes entirely from where the needle sits
between them, so a max_value that tracks the current peak makes every update look the
same and hides exactly the trend you built the widget to see. Choose the number that means "this is
the limit" — the SLO, the disk size, the tank capacity — and leave it alone.
Because the server rejects a value outside the bounds, a metric that can legitimately overshoot
needs headroom in max_value rather than a clamp at the sender. Set the ceiling above
the worst case you expect, or keep sending the raw number to a value widget and let the subtitle carry the
threshold.
The MIN and MAX end labels take the same unit as the value, so a unit that reads well next to a big number ("%", "°C") also has to read well in MAX 5%. Long words ("requests per second") are better placed in label or subtitle.
For a fraction that is already a percentage of a known whole, progress says the same thing with less configuration.
本节介绍的功能来自一个正在等待 App Store 审核的应用更新。更新上线后,此处会自动解锁。
When the recent history matters more than the ceiling, trend plots the same reading with the values that led to it.
Set the bounds and drag the needle on the playground to see the arc across the small, medium, large, and Lock Screen families.