Builtin Library
README.md
collapsible
Collapsible section with a header bar. Click the header to expand or
collapse the children. Controlled by Luau — the wrapper auto-stashes
open/closed state via ui.widgetState(id, "open") and registers a
one-time click handler with the surrounding Z.app so existing demos
that pass defaultOpen = true keep working unchanged.
Exports
collapsible(header: any?, children: { any }?, opts: CollapsibleOpts?) -> WidgetNode— build a collapsible widget node with the supplied header and children.
Types:
CollapsibleOpts = { id?, props?, style?, defaultOpen?, app? }
Usage
local collapsible = require("@builtin::modules.zui.widget.collapsible")
collapsible(label("Advanced"), {
-- collapsible children here
}, { id = "advanced-section", defaultOpen = false })
Notes
- Inside
Z.app: state is auto-managed viaui.widgetState+ a one-timeapp:onhandler keyed offid. - Outside
Z.app: falls back to a static render keyed offdefaultOpen; the caller must driveprops.openand react toValueChanged(new_open)themselves. - State APIs are flat top-level FFI functions —
ui.widgetState(id, key)andui.widgetStateSet(id, key, value), notui.widgetState.set. idis required for cross-frame state to persist. Without an id, the widget renders but the toggle won't reflect — the wrapper logs no warning, just degrades gracefully.