Skip to content
S3ctor’s S3cret St4sh
api

grid

Arrange items into fixed-column horizontal rows.

Builds a vertical Flex containing horizontal Flex rows. items are assigned in order; columns defaults to 1, and values below 1 are treated as 1.

Example

local ui = require 'openmw.ui'
local util = require 'openmw.util'
local H3UI = require('openmw.interfaces').H3UI

local iconSize = util.vector2(72, 72)
local red = util.color.rgb(1, 0, 0)
local green = util.color.rgb(0, 1, 0)
local blue = util.color.rgb(0, 0, 1)

ui.create {
  type = ui.TYPE.Container,
  layer = 'Windows',
  content = ui.content {
    H3UI.grid {
      columns = 3,
      items = {
        H3UI.itemSlot {
          resource = { path = 'white' },
          count = 1,
          iconProps = { size = iconSize, color = red },
        },
        H3UI.itemSlot {
          resource = { path = 'white' },
          count = 2,
          iconProps = { size = iconSize, color = green },
        },
        H3UI.itemSlot {
          resource = { path = 'white' },
          count = 3,
          iconProps = { size = iconSize, color = blue },
        },
      },
    },
  },
}

Parameters

FieldTypeDescription
itemstableChild layouts assigned in order.
columnsinteger?Items per row; defaults to 1.
columnGapnumber?Horizontal space inserted between items in each row.
rowGapnumber?Vertical space inserted between generated rows.
rowPropstable?Properties copied to each generated row.
templateopenmw.ui.Template?Replaces the default grid template.

Common layout fields are documented on the UI Components overview.

See also

list · itemSlot · row