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

# Grid

Arranges its items in a grid with a given number of columns.

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [],
  "layout": {
    "type": "RGrid",
    "props": { "cols": 3 },
    "items": [
      {
        "type": "RLabel",
        "props": {
          "label": "1",
          "classes": {
            "root": "flex items-center justify-center h-16 rounded-lg border border-solid border-hawkes-blue bg-titan-white",
            "sublabel": "hidden"
          }
        }
      },
      {
        "type": "RLabel",
        "props": {
          "label": "2",
          "classes": {
            "root": "flex items-center justify-center h-16 rounded-lg border border-solid border-hawkes-blue bg-titan-white",
            "sublabel": "hidden"
          }
        }
      },
      {
        "type": "RLabel",
        "props": {
          "label": "3",
          "classes": {
            "root": "flex items-center justify-center h-16 rounded-lg border border-solid border-hawkes-blue bg-titan-white",
            "sublabel": "hidden"
          }
        }
      },
      {
        "type": "RLabel",
        "props": {
          "label": "4",
          "classes": {
            "root": "flex items-center justify-center h-16 rounded-lg border border-solid border-hawkes-blue bg-titan-white",
            "sublabel": "hidden"
          }
        }
      },
      {
        "type": "RLabel",
        "props": {
          "label": "5",
          "classes": {
            "root": "flex items-center justify-center h-16 rounded-lg border border-solid border-hawkes-blue bg-titan-white",
            "sublabel": "hidden"
          }
        }
      },
      {
        "type": "RLabel",
        "props": {
          "label": "6",
          "classes": {
            "root": "flex items-center justify-center h-16 rounded-lg border border-solid border-hawkes-blue bg-titan-white",
            "sublabel": "hidden"
          }
        }
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

## Usage

```json
{
  "type": "RGrid",
  "props": { "cols": 3 },
  "items": [
    { "type": "RIconStat", "props": { "title": "Revenue" } },
    { "type": "RIconStat", "props": { "title": "Orders" } },
    { "type": "RIconStat", "props": { "title": "Average order" } }
  ]
}
```

Items fill the grid from left to right, starting a new row when one is full. Rows are added as needed, so `rows` is only required when items span several rows.

## Examples

### Spanning columns and rows

Give an item `col-span-<n>` or `row-span-<n>` in its own `classes.rootExtra` to make it take several cells. `col-span-full` takes the whole row.

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [],
  "layout": {
    "type": "RGrid",
    "props": { "cols": 4 },
    "items": [
      {
        "type": "RLabel",
        "props": {
          "label": "col-span-2",
          "classes": {
            "root": "flex items-center justify-center h-full min-h-16 rounded-lg border border-solid border-hawkes-blue bg-titan-white",
            "rootExtra": "col-span-2",
            "sublabel": "hidden"
          }
        }
      },
      {
        "type": "RLabel",
        "props": {
          "label": "1",
          "classes": {
            "root": "flex items-center justify-center h-full min-h-16 rounded-lg border border-solid border-hawkes-blue bg-titan-white",
            "rootExtra": "",
            "sublabel": "hidden"
          }
        }
      },
      {
        "type": "RLabel",
        "props": {
          "label": "row-span-2",
          "classes": {
            "root": "flex items-center justify-center h-full min-h-16 rounded-lg border border-solid border-hawkes-blue bg-titan-white",
            "rootExtra": "row-span-2",
            "sublabel": "hidden"
          }
        }
      },
      {
        "type": "RLabel",
        "props": {
          "label": "2",
          "classes": {
            "root": "flex items-center justify-center h-full min-h-16 rounded-lg border border-solid border-hawkes-blue bg-titan-white",
            "rootExtra": "",
            "sublabel": "hidden"
          }
        }
      },
      {
        "type": "RLabel",
        "props": {
          "label": "col-span-2",
          "classes": {
            "root": "flex items-center justify-center h-full min-h-16 rounded-lg border border-solid border-hawkes-blue bg-titan-white",
            "rootExtra": "col-span-2",
            "sublabel": "hidden"
          }
        }
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

### Dashboard rows

A common layout is a grid of stats over a grid of charts, with a wide chart next to a narrow list:

```jsonc
{
  "type": "RCol",
  "items": [
    {
      "type": "RGrid",
      "props": { "cols": 3 },
      "items": [
        // three stats
      ]
    },
    {
      "type": "RGrid",
      "props": { "cols": 3 },
      "items": [
        {
          "type": "RCard",
          "props": { "title": "Revenue by month", "classes": { "rootExtra": "relative h-72 col-span-2" } },
          "items": [
            // a chart
          ]
        },
        {
          "type": "RCard",
          "props": { "title": "Top cities", "classes": { "rootExtra": "relative h-72" } },
          "items": [
            // a list
          ]
        }
      ]
    }
  ]
}
```

The dashboard on the [Introduction](https://docs.rierino.com/sdk-dv-ui/getting-started/readme.md) page is built this way.

## Props

| Prop      | Type     | Default | Description                                                   |
| --------- | -------- | ------- | ------------------------------------------------------------- |
| `cols`    | `number` |         | Number of columns, 1 to 8.                                    |
| `rows`    | `number` |         | Number of rows, 1 to 8. Without it, rows are added as needed. |
| `classes` | `object` |         | Class names for the grid, see Classes below.                  |

In the Rierino designer: **Columns**, **Rows** and **Classes**.

{% hint style="warning" %}
**1 to 8**

The stylesheet has the column, row and span classes for 1 to 8 only. Larger values have no effect.
{% endhint %}

## Classes

| Part   | Built-in classes                 |
| ------ | -------------------------------- |
| `root` | `grid gap-x-4 gap-y-4 pb-2 pt-2` |

`cols` and `rows` add `grid-cols-<n>` and `grid-rows-<n>`. Set `classes.root` to replace the built-in classes, or `classes.rootExtra` to add to them.


---

# 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.rierino.com/sdk-dv-ui/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.
