Glorpia Docs
Instances

UIGridLayout

Automatically arranges sibling GUI objects into evenly sized grid cells.

Properties

NameTypeDescription
CellPaddingUDim2Horizontal and vertical spacing between grid cells. Default: UDim2.new(0, 5, 0, 5).
CellSizeUDim2Size assigned to each arranged GUI object. Default: UDim2.new(0, 100, 0, 100).
FillDirectionEnum.FillDirectionAxis filled first by the grid. Default: Enum.FillDirection.Horizontal.
FillDirectionMaxCellsnumberMaximum cells placed along the fill axis. A value of 0 derives the count from the available parent size. Default: 0.
HorizontalAlignmentEnum.HorizontalAlignmentHorizontal alignment of the complete grid. Default: Enum.HorizontalAlignment.Left.
VerticalAlignmentEnum.VerticalAlignmentVertical alignment of the complete grid. Default: Enum.VerticalAlignment.Top.
StartCornerEnum.StartCornerCorner from which cell placement begins. Default: Enum.StartCorner.TopLeft.
UIGridLayout affects direct visible Frame, ScrollingFrame, TextLabel and TextButton children of its parent. Each arranged child's rendered size is the current CellSize.
If more than one layout component is directly parented to the same GUI object, the first UIListLayout or UIGridLayout in that parent's child hierarchy is used.

Ordering

Children are placed in hierarchy order. FillDirection controls whether rows or columns fill first, FillDirectionMaxCells limits the fill axis, and StartCorner changes the corner from which placement begins.

Example

Luau
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, 420, 0, 300)
frame.Parent = game:GetService("StarterGui").ScreenGui

local grid = Instance.new("UIGridLayout")
grid.CellSize = UDim2.new(0, 96, 0, 72)
grid.CellPadding = UDim2.new(0, 8, 0, 8)
grid.FillDirection = Enum.FillDirection.Horizontal
grid.FillDirectionMaxCells = 4
grid.StartCorner = Enum.StartCorner.TopLeft
grid.Parent = frame

Related