> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/apps/components/layout/grid-layout.md). Agents can also search and read this documentation through its [MCP server](https://docs.devolutions.net/~gitbook/mcp).

# Grid Layout

Design drag and drop grid layouts in PowerShell Universal apps, arranging components visually and persisting user customized layouts.

## Grid Layout

The Grid Layout component is useful for defining layouts in a visual manner. You can drag and drop components using the web interface to automatically define the layout as JSON.

## Designing Layouts

You can employ the -Design parameter to configure the layout of your page. This allows dynamic drag and drop of components that you place within the content of the grid layout. As you drag and resize components, the layout will be copied to your clipboard. Note: All components must possess a static -Id

In design mode, components can be dragged and resized even if you do not use the `-Draggable` and `-Resizable` parameters. In the layout JSON, each component is identified as `grid-element-` followed by its `-Id` (for example, `grid-element-Paper1`).

```
New-UDGridLayout -Content { 1..10 | ForEach-Object { New-UDPaper -Id "Paper$_" -Content { New-UDTypography -Text $_ } -Elevation 5 } } -Design
```

## Using Layouts

Once you have configured the layout to fit your needs, you can paste the JSON into your script and assign it with the -Layout parameter. Remove the -Design parameter to lock elements in place.

```
$Layout = '{"lg":[{"w":7,"h":7,"x":5,"y":0,"i":"grid-element-Paper1","moved":false,"static":false},{"w":7,"h":5,"x":5,"y":7,"i":"grid-element-Paper2","moved":false,"static":false},{"w":1,"h":1,"x":0,"y":0,"i":"grid-element-Paper3","moved":false,"static":false},{"w":1,"h":1,"x":0,"y":1,"i":"grid-element-Paper4","moved":false,"static":false},{"w":1,"h":1,"x":0,"y":2,"i":"grid-element-Paper5","moved":false,"static":false},{"w":1,"h":1,"x":0,"y":3,"i":"grid-element-Paper6","moved":false,"static":false},{"w":1,"h":1,"x":0,"y":4,"i":"grid-element-Paper7","moved":false,"static":false},{"w":1,"h":1,"x":0,"y":5,"i":"grid-element-Paper8","moved":false,"static":false},{"w":1,"h":1,"x":0,"y":6,"i":"grid-element-Paper9","moved":false,"static":false},{"w":1,"h":1,"x":0,"y":7,"i":"grid-element-Paper10","moved":false,"static":false}]}' 
New-UDGridLayout -Content { 1..10 | ForEach-Object { New-UDPaper -Id "Paper$_" -Content { New-UDTypography -Text $_ } -Elevation 5 } } -Layout $Layout
```

## Allowing Users to Modify Layouts

You can allow your users to dynamically modify layouts by using the -Draggable, -Resizable and -Persist parameters. The layout changes are stored locally so the next time each user visits a page, it will be loaded with their chosen layout.

```
New-UDGridLayout -Content { 1..10 | ForEach-Object { New-UDPaper -Id "Paper$_" -Content { New-UDTypography -Text $_ } -Elevation 5 } } -Draggable -Resizable -Persist
```

With `-Persist`, the layout is saved in the browser's local storage for the URL path of the page, so each browser keeps its own layout. When `-Layout` is also set, the page always starts from the `-Layout` value: a persisted layout is only reloaded when `-Layout` is not set.

## Parameters

| Name                      | Type        | Description                                                                                                                 |
| ------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------- |
| Id                        | String      | The ID of this component. Defaults to a random GUID.                                                                        |
| Content                   | ScriptBlock | Mandatory. The components to place in the grid layout. Each component must have a static `-Id`.                             |
| Layout                    | String      | The layout as a JSON string, as copied in design mode.                                                                      |
| RowHeight                 | Int         | The height of each row, in pixels. Default: `30`.                                                                           |
| LargeColumns              | Int         | The number of columns at the large breakpoint. Default: `12`.                                                               |
| MediumColumns             | Int         | The number of columns at the medium breakpoint. Default: `10`.                                                              |
| SmallColumns              | Int         | The number of columns at the small breakpoint. Default: `6`.                                                                |
| ExtraSmallColumns         | Int         | The number of columns at the extra small breakpoint. Default: `4`.                                                          |
| ExtraExtraSmallColumns    | Int         | The number of columns at the extra extra small breakpoint. Default: `2`.                                                    |
| LargeBreakpoint           | Int         | The width of the large breakpoint, in pixels. Default: `1200`.                                                              |
| MediumBreakpoint          | Int         | The width of the medium breakpoint, in pixels. Default: `996`.                                                              |
| SmallBreakpoint           | Int         | The width of the small breakpoint, in pixels. Default: `768`.                                                               |
| ExtraSmallBreakpoint      | Int         | The width of the extra small breakpoint, in pixels. Default: `480`.                                                         |
| ExtraExtraSmallBreakpoint | Int         | The width of the extra extra small breakpoint, in pixels. Default: `0`.                                                     |
| Draggable                 | Switch      | Users can drag the components.                                                                                              |
| Resizable                 | Switch      | Users can resize the components.                                                                                            |
| Persist                   | Switch      | Saves the layout changes in the browser's local storage.                                                                    |
| Design                    | Switch      | Turns on design mode: components can be dragged and resized, and the layout JSON is copied to the clipboard on each change. |

## API

* [New-UDGridLayout](https://docs.devolutions.net/powershell-universal/powershell-commands/new-udgridlayout.md)


---

# 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://docs.devolutions.net/powershell-universal/apps/components/layout/grid-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.
