Skip to content

Grid Layout

ss.ui.grid(opts, children) computes fixed-column grid cell rects for an array of child definitions.

lua
for _, def in ipairs(ss.ui.grid({
    rect = { unit = "px", x = 10, y = 50, w = 460, h = 200 },
    cols = 3,
    gap = 4,
    padding = 8,
    row_height = 60,
}, {
    { id = "c1", type = "panel", style = { bg = "#1E293B" } },
    { id = "c2", type = "panel", style = { bg = "#334155" } },
    { id = "c3", type = "panel", style = { bg = "#1E293B" } },
    { id = "c4", type = "panel", style = { bg = "#334155" } },
    { id = "c5", type = "panel", style = { bg = "#1E293B" } },
    { id = "c6", type = "panel", style = { bg = "#334155" } },
})) do
    ui:element(def)
end
OptionDescription
rectContainer rect
colsNumber of columns (default 2)
gapGap between cells in pixels (default 4)
paddingInset from container edges
row_heightFixed row height (if omitted, cells are square)

Returns the children array with computed rects applied.

⚠️ This documentation was AI-generated and may contain inaccuracies. Please submit pull requests with corrections as needed.