NUI / Components / Layout

UniformGridPanel

ImplementedLayout

UniformGridPanel places children in a grid where cells share a uniform size.

Supported as an evenly sized grid layout container.

Overview

UniformGridPanel places children in a grid where cells share a uniform size.

When to use

  • Inventory slots.
  • Icon grids.
  • Fixed tiles.
  • Regular menu grids.

Children

Supports normal children.

nui
children {
    Text ChildText {
        text: "THIS IS THE CHILD COMPONENT"
        row: 0
        column: 0
    }
}

Basic syntax

nui
UniformGridPanel InventoryGrid {
    minDesiredSlotWidth: 64
    minDesiredSlotHeight: 64

    children {
        Text ChildText {
            text: "THIS IS THE CHILD COMPONENT"
            row: 0
            column: 0
        }
    }
}

Supported properties

PropertyTypeRequiredDefaultDescription
minDesiredSlotWidthnumberNoUnsetMinimum grid slot width.
minDesiredSlotHeightnumberNoUnsetMinimum grid slot height.
slotPaddingmarginNomargin(0)Padding around grid slots.
widthnumberNoAutoDesired width.
heightnumberNoAutoDesired height.
paddingmarginNomargin(0)Inner padding.
backgroundColorcolorNoTransparentOptional background color.
horizontalAlignenumNoInheritedComponent horizontal alignment.
verticalAlignenumNoInheritedComponent vertical alignment.
opacitynumberNo1Render opacity.
layerintegerNoContext defaultLayer order inside layered parents.
visibleboolNotrueVisibility flag.

Contextual properties

Contextual property rules

Children of UniformGridPanel may use grid slot properties. UniformGridPanel itself may receive stack, canvas, wrap, or ExpandableArea slot properties only when it is a child of the matching parent. See section 7.

Full syntax example

nui
UniformGridPanel InventoryGrid {
    minDesiredSlotWidth: 64
    minDesiredSlotHeight: 64
    slotPadding: margin(4)
    width: 360
    height: 240
    padding: margin(8)
    backgroundColor: "#0F172A"
    horizontalAlign: fill
    verticalAlign: top
    opacity: 1
    layer: 1
    visible: true

    children {
        Text ChildText {
            text: "THIS IS THE CHILD COMPONENT"
            row: 0
            column: 0
            rowSpan: 1
            columnSpan: 1
            nudge: vec2(0, 0)
        }
    }
}

Limitations

  • rowFill and columnFill are GridPanel properties, not normal UniformGridPanel properties.
  • Do not use gap on UniformGridPanel.