> 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.md). Agents can also search and read this documentation through its [MCP server](https://docs.devolutions.net/~gitbook/mcp).

# Grid

Build responsive grid layouts in PowerShell Universal apps using a 12 column system with configurable spacing, rows, and columns.

The responsive layout grid adapts to screen size and orientation, ensuring consistency across layouts.

The grid creates visual consistency between layouts while allowing flexibility across a wide variety of designs. Material Design’s responsive UI is based on a 12-column grid layout.

## Basic Layout

```powershell
New-UDGrid -Container -Content {
    New-UDGrid -Item -ExtraSmallSize 12 -Content {
        New-UDPaper -Content { "xs-12" } -Elevation 2
    }
    New-UDGrid -Item -ExtraSmallSize 6 -Content {
        New-UDPaper -Content { "xs-6" } -Elevation 2
    }
    New-UDGrid -Item -ExtraSmallSize 6 -Content {
        New-UDPaper -Content { "xs-6" } -Elevation 2
    }
    New-UDGrid -Item -ExtraSmallSize 3 -Content {
        New-UDPaper -Content { "xs-3" } -Elevation 2
    }
    New-UDGrid -Item -ExtraSmallSize 3 -Content {
        New-UDPaper -Content { "xs-3" } -Elevation 2
    }
    New-UDGrid -Item -ExtraSmallSize 3 -Content {
        New-UDPaper -Content { "xs-3" } -Elevation 2
    }
    New-UDGrid -Item -ExtraSmallSize 3 -Content {
        New-UDPaper -Content { "xs-3" } -Elevation 2
    }
}
```

## Spacing

Adjust the spacing between items in the grid

```powershell
New-UDDynamic -Id 'spacingGrid' -Content {
    $Spacing = (Get-UDElement -Id 'spacingSelect').value

    New-UDGrid -Spacing $Spacing -Container -Content {
        New-UDGrid -Item -ExtraSmallSize 3 -Content {
            New-UDPaper -Content { "xs-3" } -Elevation 2
        }
        New-UDGrid -Item -ExtraSmallSize 3 -Content {
            New-UDPaper -Content { "xs-3" } -Elevation 2
        }
        New-UDGrid -Item -ExtraSmallSize 3 -Content {
            New-UDPaper -Content { "xs-3" } -Elevation 2
        }
        New-UDGrid -Item -ExtraSmallSize 3 -Content {
            New-UDPaper -Content { "xs-3" } -Elevation 2
        }
    }
}

New-UDSelect -Id 'spacingSelect' -Label Spacing -Option {
    for($i = 0; $i -lt 10; $i++)
    {
        New-UDSelectOption -Name $i -Value $i
    }
} -OnChange { Sync-UDElement -Id 'spacingGrid' } -DefaultValue 3
```

## Row and Columns

You can also use the `New-UDRow` and `New-UDColumn` functions when working with the grid.

```powershell
New-UDRow -Columns {
    New-UDColumn -SmallSize 12 -Content {
        New-UDPaper -Content { "xs-12" } -Elevation 2
    }
    New-UDColumn -SmallSize 12 -Content {
        New-UDPaper -Content { "xs-12" } -Elevation 2
    }
}
```

When working with columns, you will need to specify the medium and large sizes, otherwise they will always be set to 12.

```powershell
New-UDRow -Columns {
    New-UDColumn -SmallSize 12 -MediumSize 12 -LargeSize 12 -Content {
        New-UDPaper -Content { "xs-12" } -Elevation 2
    }
    New-UDColumn -SmallSize 12 -MediumSize 12 -LargeSize 12 -Content {
        New-UDPaper -Content { "xs-12" } -Elevation 2
    }
}
```

`New-UDRow` creates a grid container (`New-UDGrid -Container`) and `New-UDColumn` creates a grid item (`New-UDGrid -Item`). `-ExtraSmallSize` and `-ExtraLargeSize` are only set on a column when you specify them.

## Parameters

### New-UDGrid

`New-UDGrid` has two parameter sets: use `-Container` for a row of items, or `-Item` for an item inside a container.

| Name           | Type        | Description                                                                                                                        |
| -------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| Id             | String      | The ID of the component. Defaults to a random GUID.                                                                                |
| Container      | Switch      | Makes the grid a container (a row). Container parameter set.                                                                       |
| Spacing        | Int         | The spacing between items, from `0` to `10`. Container parameter set only.                                                         |
| Item           | Switch      | Makes the grid an item inside a container. Item parameter set.                                                                     |
| ExtraSmallSize | Int         | The number of columns (`1` to `12`) used on extra small screens. Alias: `Size`. Item parameter set only.                           |
| SmallSize      | Int         | The number of columns (`1` to `12`) used on small screens. Item parameter set only.                                                |
| MediumSize     | Int         | The number of columns (`1` to `12`) used on medium screens. Item parameter set only.                                               |
| LargeSize      | Int         | The number of columns (`1` to `12`) used on large screens. Item parameter set only.                                                |
| ExtraLargeSize | Int         | The number of columns (`1` to `12`) used on extra large screens. Item parameter set only.                                          |
| Children       | ScriptBlock | The components in this grid. Alias: `Content`.                                                                                     |
| ClassName      | String      | A CSS class to apply to the grid.                                                                                                  |
| Direction      | String      | The direction of the grid: `row` (default), `column`, `column-reverse` or `row-reverse`.                                           |
| RowSpacing     | Object      | The spacing between rows.                                                                                                          |
| ColumnSpacing  | Object      | The spacing between columns.                                                                                                       |
| JustifyContent | String      | The alignment of items along the main axis: `flex-start`, `flex-end`, `center`, `space-between`, `space-around` or `space-evenly`. |
| AlignItems     | String      | The alignment of items along the cross axis: `flex-start`, `flex-end`, `center`, `baseline` or `stretch`.                          |
| Version        | String      | The Material UI grid version: `1` (default, Grid) or `2` (Grid2).                                                                  |
| Style          | Hashtable   | CSS styles to apply to the grid.                                                                                                   |

### New-UDRow

| Name    | Type        | Description                                              |
| ------- | ----------- | -------------------------------------------------------- |
| Id      | String      | The ID of the row. Defaults to a random GUID.            |
| Columns | ScriptBlock | The columns in this row. Use `New-UDColumn`. Position 0. |
| Style   | Hashtable   | CSS styles to apply to the row.                          |

### New-UDColumn

| Name           | Type        | Description                                                                              |
| -------------- | ----------- | ---------------------------------------------------------------------------------------- |
| Id             | String      | The ID of the column. Defaults to a random GUID.                                         |
| SmallSize      | Int         | The number of columns (`1` to `12`) used on small screens. Default: `12`. Alias: `Size`. |
| MediumSize     | Int         | The number of columns (`1` to `12`) used on medium screens. Default: `12`.               |
| LargeSize      | Int         | The number of columns (`1` to `12`) used on large screens. Default: `12`.                |
| ExtraSmallSize | Int         | The number of columns (`1` to `12`) used on extra small screens. No default.             |
| ExtraLargeSize | Int         | The number of columns (`1` to `12`) used on extra large screens. No default.             |
| Content        | ScriptBlock | The components in this column. Position 1.                                               |
| Style          | Hashtable   | CSS styles to apply to the column.                                                       |

## API

* [New-UDGrid](https://docs.devolutions.net/powershell-universal/powershell-commands/new-udgrid.md)
* [New-UDRow](https://docs.devolutions.net/powershell-universal/powershell-commands/new-udrow.md)
* [New-UDColumn](https://docs.devolutions.net/powershell-universal/powershell-commands/new-udcolumn.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.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.
