▣
module · drop-in viewer
node
Core widget-table constructor used by every zui widget. Returned tables are interoperable with hand-written widget trees, so user-built widgets can reuse the exact same primitive without depending on the rest of zui.
by·posted 2mo ago
What it does
node
Core widget-table constructor used by every zui widget. Returned tables are interoperable with hand-written widget trees, so user-built widgets can reuse the exact same primitive without depending on the rest of zui.
Exports
node(widgetType: string, opts: Opts?, children: any?) -> any— build the widget table. Returned directly by the module.
Types:
Opts = { id?: string, classes?: any, class?: any, props?: any, style?: any }
Usage
local node = require("@builtin::modules.zui.widget.node")
-- User-built widget composed on top of node:
return function(text, opts)
return node("label", { props = { text = text } })
end
Notes
- Accepts either a single child table or an array of children; single
children are wrapped automatically (matches
scroll.module's fix from #2331). classesmay be a string (space-separated) or an array — both normalise to an array of class names.classis accepted as an alias forclassesfor ergonomic call sites.- Returning a function (not a table) keeps consumers terse and avoids
callers needing to know whether the constructor lives on
M.xor the module itself.
Discussion
Scoped to this part · feeds back into the world's score.
Sign in to post.sign in
No comments yet. Be the first.