Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commitdd348ac6c3

README.md

statusLabel

Numeric label that auto-picks a class by threshold ranges. The caller passes { good = X, warn = Y } (sorted ascending). Values below good get the good class; below warn get warn; the rest get bad. Non-numeric values get the bad class so a missing/erroring data source is visually loud. Defaults to the engine theme's debug-timing-good/warn/bad classes shipped in themes/debug.yaml.

Exports

  • statusLabel(value, thresholds, opts?) -> Node — returns a coloured label widget. Module returns the builder function directly.

Types:

  • StatusClasses = { good: string, warn: string, bad: string }
  • StatusThresholds = { good: number?, warn: number? }
  • StatusLabelOpts = { id?, classes?, ratioOf?, fmt?, bold?, color?, fontSize? }

Usage

local statusLabel = require("@builtin::modules.zui.widget.statusLabel")

statusLabel(dtMs, { good = 16, warn = 33 })

statusLabel(used, { good = 0.8, warn = 0.95 }, {
    ratioOf = max,
    fmt     = function(v) return string.format("%.1f%%", v * 100) end,
})

Notes

  • Pass ratioOf to compare value / ratioOf against the thresholds while still feeding the raw value to fmt. Non-positive ratioOf values are ignored.
  • Pass custom classes = { good, warn, bad } to retarget styling. The default classes live in themes/debug.yaml.
  • Non-numeric value always renders in the bad class so a broken data source is visually loud.