# Grid

- **Section:** Components
- **URL:** https://refast.fastapicloud.dev/docs/components/grid
- **Markdown:** https://refast.fastapicloud.dev/docs/components/grid.md
- **Source:** https://github.com/idling-mind/refast-docs/blob/main/docs/pages/components/layout/grid.py
- **Live examples:** the widgets on this page need a browser; open the URL above to try them.
- **Applies to:** refast 0.12.2

CSS Grid container for equal-column layouts.

```python
from refast.components import Grid

Grid(
    columns=3,
    gap=4,
    children=[Card(...) for _ in range(6)],
)
```

Cell 1

Cell 2

Cell 3

Cell 4

Cell 5

Cell 6

## Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `children` | `list \| Component \| None` | `None` | Grid cell components |
| `columns` | `int \| str` | `1` | Number of equal columns, or a CSS `gridTemplateColumns` string |
| `rows` | `int \| str \| None` | `None` | Number of equal rows, or a CSS `gridTemplateRows` string |
| `gap` | `int` | `4` | Gap between cells (Tailwind spacing unit) |
| `id` | `str \| None` | `None` | Unique element ID |
| `class_name` | `str` | `""` | Extra Tailwind classes |

## Advanced: Custom Template

Pass a CSS string to `columns` or `rows` for custom sizing:

```python
Grid(
    columns="200px 1fr 200px",
    gap=4,
    children=[sidebar, main, aside],
)
```

## Examples

```python
# 3-column card grid
Grid(
    columns=3,
    gap=6,
    class_name="max-w-5xl",
    children=[
        Card(children=[CardHeader(title=title)])
        for title in ["Alpha", "Beta", "Gamma"]
    ],
)
```

---

Part of the Refast documentation: [all pages](https://refast.fastapicloud.dev/llms.txt), [everything on one page](https://refast.fastapicloud.dev/llms-full.txt), [search](https://refast.fastapicloud.dev/api/search?q=save_prop).
