Instances
UIGridLayout
Automatically arranges sibling GUI objects into evenly sized grid cells.
Properties
| Name | Type | Description |
|---|---|---|
CellPadding | UDim2 | Horizontal and vertical spacing between grid cells. Default: UDim2.new(0, 5, 0, 5). |
CellSize | UDim2 | Size assigned to each arranged GUI object. Default: UDim2.new(0, 100, 0, 100). |
FillDirection | Enum.FillDirection | Axis filled first by the grid. Default: Enum.FillDirection.Horizontal. |
FillDirectionMaxCells | number | Maximum cells placed along the fill axis. A value of 0 derives the count from the available parent size. Default: 0. |
HorizontalAlignment | Enum.HorizontalAlignment | Horizontal alignment of the complete grid. Default: Enum.HorizontalAlignment.Left. |
VerticalAlignment | Enum.VerticalAlignment | Vertical alignment of the complete grid. Default: Enum.VerticalAlignment.Top. |
StartCorner | Enum.StartCorner | Corner 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