Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commitdd348ac6c3

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 via ui.widgetState + a one-time app:on handler keyed off id.
  • Outside Z.app: falls back to a static render keyed off defaultOpen; the caller must drive props.open and react to ValueChanged(new_open) themselves.
  • State APIs are flat top-level FFI functions — ui.widgetState(id, key) and ui.widgetStateSet(id, key, value), not ui.widgetState.set.
  • id is 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.