Reference API Roblox

Engine API

Website

Related

Reference API Roblox

UIGridLayout

Positions sibling UI elements by filling rows using the space of the parent UI element.

Member index 6

HistoryMember
726AbsoluteCellCount: Vector2
726AbsoluteCellSize: Vector2
726CellPadding: UDim2
726CellSize: UDim2
726FillDirectionMaxCells: int
726StartCorner: StartCorner
inherited from UIGridStyleLayout
726AbsoluteContentSize: Vector2
726FillDirection: FillDirection
726HorizontalAlignment: HorizontalAlignment
726SortOrder: SortOrder
726VerticalAlignment: VerticalAlignment
573ApplyLayout(): null
573SetCustomSortFunction(function: Function = nil): null
inherited from Instance
726Archivable: bool
726Capabilities: SecurityCapabilities
726IsInSandbox: bool
726Name: string
726Parent: Instance
726PredictionMode: PredictionMode
726Sandboxed: bool
726UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
707GetDescendants(): Instances
486GetFullName(): string
706GetStyled(name: string, selector: string?): Variant
657GetStyledPropertyChangedSignal(property: string): RBXScriptSignal
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
664IsPropertyModified(property: string): bool
698QueryDescendants(selector: string): Instances
573Remove(): null
576RemoveTag(tag: string): null
664ResetPropertyToDefault(property: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
726children(): Instances
726clone(): Instance
726destroy(): null
726findFirstChild(name: string, recursive: bool = false): Instance
726getChildren(): Instances
726isDescendantOf(ancestor: Instance): bool
726remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
657StyledPropertiesChanged()
726childAdded(child: Instance)
inherited from Object
726ClassName: string
726className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
726isA(className: string): bool
647Changed(property: string)

Removed member index 6

HistoryMember
274AbsoluteSize: Vector2
274Alignment: GridAlignment
274FillDirection: GridFillOrder
274SortOrder: GridSortOrder
274ApplyLayout(): void
274SetCustomSortFunction(function: Function): void

Description

A UIGridLayout (not to be confused with the abstract UIGridStyleLayout from which this class inherits) lays out sibling UI elements in multiple rows within the parent UI element, adding elements to a row one-by-one until the next element would not fit. It then continues adding elements in the next row. A UIGridLayout will take UI elements' GuiObject.Size and GuiObject.Position under control. While under control, these UI elements' properties will not be editable in the Properties window.

By default, it lays out elements in ascending order where lower values take more priority over higher values, but this can be changed to use elements' names by changing UIListLayout.SortOrder to Name. A UIListLayout will automatically re-layout elements when elements are added/removed, or if a relevant property changes: GuiObject.LayoutOrder or Instance.Name. This can be triggered manually by calling UIGridStyleLayout:ApplyLayout(), though this is typically not necessary.

The actual cell sizes are the same for all cells. A UIGridLayout will respect UI constraints placed with it, such as UISizeConstraint and UIAspectRatioConstraint. Elements in the layout can span multiple cells if they have a UISizeConstraint with a MinSize set higher than the CellSize. It is possible to limit the number of elements per row using UIGridLayout.FillDirectionMaxCells. If set to 1, it is possible to create a single row of elements (as each element would be positioned in its own row).

This layout is appropriate when line breaks are OK after arbitrary cells. For example, a set of inventory spaces is a good use of this layout. If building a table of values in which a line break is not appropriate in the middle of tabular data, it might be a better idea to use a UITableLayout instead.

History 45

Members 6

AbsoluteCellCount

TypeDefault
Vector2

Measures the maximum number of elements in each direction. Read-only.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 5

Tags: [ReadOnly, NotReplicated]

AbsoluteCellSize

TypeDefault
Vector2

Provides the size of each element of the grid in offsets. Read-only. Not affected by any UIScale, UISizeConstraint or UIAspectRatioConstraint applied to any individual element in the grid.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 5

Tags: [ReadOnly, NotReplicated]

CellPadding

TypeDefault
UDim2

(default {0, 5},{0, 5}) Determines how much space there is between elements in the grid. As with all UDim2s, this space can be both in a percentage of the parent container's size and raw pixel offset.

History 5

CellSize

TypeDefault
UDim2

(default {0, 100},{0, 100}) Determines the size of each element in the grid. As with all UDim2s, this size can be both in a percentage of the parent container's size and raw pixel offset. If the element being size has a UIConstraint then the size will be determined by the constraint, not the grid.

History 5

FillDirectionMaxCells

TypeDefault
int

FillDirectionMaxCells determines the number of cells in the grid that can be used before continuing on the next row/column (whether this is a row or column is dependent on UIGridStyleLayout.FillDirection). This value must be non-negative.

  • If set to zero, there is no maximum number of cells that may appear in one row/column except for how many can fit within the parent UI element.
  • If set to one, this creates a list similar to those created by UIListLayout.

History 5

StartCorner

TypeDefault
StartCorner

StartCorner (StartCorner) determines from which corner the grid starts laying out UI elements. The grid continues in the UIGridStyleLayout.FillDirection, filling elements one by one until UIGridLayout.FIllDirectionMaxCells cells have been laid out in that row/column or if all the parent UI element's space has been occupied by previous cells.

Above, the potion is the first ImageLabel, followed by the gem and the sword. The UIGridLayout is using a StartCorner of BottomRight. The UIGridStyleLayout.FillDirection is Horizontal.

History 6

Removed members 6

AbsoluteSize

TypeDefault
Vector2
This property is read-only. Its value can be read, but it cannot be modified.

History 2

Tags: [ReadOnly]

Alignment

TypeDefault
GridAlignment

History 2

ApplyLayout

Parameters (0)
No parameters.
Returns (1)
void

History 2

FillDirection

TypeDefault
GridFillOrder

History 2

SetCustomSortFunction

Parameters (1)
functionFunction
Returns (1)
void

History 2

SortOrder

TypeDefault
GridSortOrder

History 2

Settings