---
title: "UIGridLayout"
description: "Automatically arranges sibling GUI objects into evenly sized grid cells."
canonical: "https://docs.glorpia.com/instances/uigridlayout"
markdown: "https://docs.glorpia.com/instances/uigridlayout.md"
---
# UIGridLayout

Automatically arranges sibling GUI objects into evenly sized grid cells.

**Category:** Instances

## 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. |

> **Note:** UIGridLayout affects direct visible Frame, ScrollingFrame, TextLabel and TextButton children of its parent. Each arranged child's rendered size is the current CellSize.

> **Note:** 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

- [UIListLayout](https://docs.glorpia.com/instances/uilistlayout.md) — Arranges children in a horizontal or vertical list.
- [Frame](https://docs.glorpia.com/instances/frame.md) — Rectangular GUI container that can own a layout.
- [ScrollingFrame](https://docs.glorpia.com/instances/scrollingframe.md) — Scrollable GUI container that can own a layout.
- [Enums](https://docs.glorpia.com/scripting/enums.md) — FillDirection, alignment and StartCorner enum values.
