> For the complete documentation index, see [llms.txt](https://lua2.fatality.win/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lua2.fatality.win/api/instances/gui/container/controlcontainer/layout.md).

# Layout

This type represents a layout control.

<figure><img src="https://2267301601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGXl3mJ7rIlEGl0zYZZu0%2Fuploads%2FHtFzx92HYpv1Cpvx0wWG%2Fimage.png?alt=media&amp;token=a7d680e5-fc3d-4f3a-bc02-efe6ca3de032" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
This type inherits [`ControlContainer`](/api/instances/gui/container/controlcontainer.md) type. All of its base methods and fields are also available in this type.
{% endhint %}

Layouts are used to override the menu's default stacking methods, such as stacking elements horizontally or in a grid. For example, putting two buttons together in the same line:

***

## \_\_call﻿ <a href="#call" id="call"></a>

[<kbd><mark style="background-color:purple;">**Constructor**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Constructs the layout.

**Arguments**

| Name        | Type                                                                                       | Description.                                         |
| ----------- | ------------------------------------------------------------------------------------------ | ---------------------------------------------------- |
| `id`        | [`ControlID`](/api/instances/gui/types/controlid.md)`\|string`                             | ID.                                                  |
| `position`  | [`Vec2`](/api/instances/draw/types/vec2.md)                                                | Position, offset from parent.                        |
| `size`      | [`Vec2`](/api/instances/draw/types/vec2.md)                                                | Size.                                                |
| `direction` | [`StackDirection`](/api/instances/gui/container/controlcontainer/layout/stackdirection.md) | The stacking method for elements inside this layout. |

**Returns**

| Type     | Description      |
| -------- | ---------------- |
| `Layout` | Layout instance. |

**Example**

```lua
local layout = gui.Layout('my_layout', draw.Vec2(), draw.Vec2(100, 24), 
    gui.StackDirection.INLINE);
    
layout.sizeToParentW = true -- Resizes layout width to parent groupbox.
    
local cb1, ctrl1 = gui.MakeControlEasy('my_cb1', 'Checkbox 1', 'checkbox')
local cb2, ctrl2 = gui.MakeControlEasy('my_cb2', 'Checkbox 2', 'checkbox')

layout:Add(ctrl1)
layout:Add(ctrl2)
```

***

## direction <a href="#call" id="call"></a>

[<kbd><mark style="background-color:purple;">**Field**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

The current direction for this layout.

***

## shouldClip <a href="#call" id="call"></a>

[<kbd><mark style="background-color:purple;">**Field**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Whether the layout should respect clipping or not.

***

## shouldCenterize <a href="#call" id="call"></a>

[<kbd><mark style="background-color:purple;">**Field**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Whether or not the layout should center elements or not. Only works for some stacking directions.

***

## stackInvisible <a href="#call" id="call"></a>

[<kbd><mark style="background-color:purple;">**Field**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Alternative stacking method

***

## showSpinner <a href="#call" id="call"></a>

[<kbd><mark style="background-color:purple;">**Field**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Puts a loading icon on top of the entire layout and blurs background. Useful for when menu items are still loading (e.g. grenade helper lists).

***

## stackOffset <a href="#call" id="call"></a>

[<kbd><mark style="background-color:purple;">**Field**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Type: [`Vec2`](/api/instances/draw/types/vec2.md)

Overrides the distance between elements inside the layout horizontally and vertically.

[^1]: This is a constructor definition for this type.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://lua2.fatality.win/api/instances/gui/container/controlcontainer/layout.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
