Builtin Library
README.md
colorSwatch
Click-only coloured swatch — a small (default 24×24) coloured rect
with a white border. Used as a click target for material chips,
palette swatches, or any visual indicator that doubles as a click
target. Implemented as an empty-text button so the engine has no
dedicated arm.
Exports
colorSwatch(color: any?, callbackId: any?, opts: ColorSwatchOpts?) -> WidgetNode— build a coloured-swatch widget node.
Types:
ColorSwatchOpts = { id?, size?, style?, border?, borderWidth?, tooltip? }
Usage
local colorSwatch = require("@builtin::modules.zui.widget.colorSwatch")
colorSwatch("#ff8855", "swatch:click", { id = "row5" })
colorSwatch("#5588ff", "pick", { size = 32, tooltip = "Pick blue" })
Notes
- Defaults:
size = 24,border = "#ffffff",borderWidth = 1,borderRadius = 4,padding = 0. - Click handling reuses the button widget — same callback-id semantics, same closure auto-wiring inside
Z.app. - Per-swatch routing pattern: encode the swatch identity into the callback id (e.g.
"swatch-" .. hex) and match withapp:on("^swatch%-(.+)$", ...).