# Element layout

The six-column grid: widths, heights, minimum sizes and what the app adjusts by itself.

[Elements in a message](https://packlets.app/en/docs/nachrichten-elemente.md) sit in a grid. Two fields decide how big an element is: `width` and `height`. The app does the rest.

## The grid

The area below a message's text is divided into **6 columns**. `width` says how many of them an element takes up:

| `width` | Width |
|---|---|
| `6` (default) | the full width |
| `3` | half |
| `2` | a third |

Elements fill the rows from left to right, in the order of your list. If the next one no longer fits in the row, a new row starts.

The matching list, in the `elements` field of `POST /v1/push`:

```json
[
  {"type": "toggle", "id": "wartung",  "label": "Maintenance", "value": true, "width": 3},
  {"type": "toggle", "id": "deploys",  "label": "Deploys", "width": 3},
  {"type": "text",   "id": "neustart", "text": "Restart", "style": "caption"},
  {"type": "button", "id": "api",      "label": "API",  "width": 2, "height": 56},
  {"type": "button", "id": "shop",     "label": "Shop", "width": 2, "height": 56},
  {"type": "button", "id": "db",       "label": "DB",   "style": "secondary", "width": 2, "height": 56}
]
```

## Height

Without `height`, an element is as tall as its content needs. With `height`, you set a **minimum height** in points. If the content needs more, the element gets taller.

What `height` is good for:

- A button becomes a big tile, for example `"height": 56`.
- A chart gets taller bars, for example `"height": 220`.

A text has no `height`. It's always as tall as its content.

## Minimum sizes

To keep everything readable and easy to tap, every element has limits:

| Element | Minimum width | Height |
|---|---|---|
| `text` | 2 columns | by content |
| `button` | 2 columns | 44 to 240 |
| `toggle` | 3 columns | 64 to 240 |
| `input` | 3 columns | 160 to 400 |
| `chart` | 3 columns | 120 to 480 |
| `table` | 3 columns | 80 to 800 |

If you give less or more, Packlets doesn't reject it but moves the value to the limit. What was changed is in the response of `POST /v1/push`, in the `warnings` field (in English, or in German with the header `Accept-Language: de`):

```json
{
  "message_id": "5b0c1a52-7c1e-4a43-9d0b-2f6f0c7d1e11",
  "warnings": ["wartung: width 2 → 3 (minimum width for toggle)", "db: height 30 → 44 (minimum height for button)"]
}
```

Only a `width` outside 1 to 6 is an error (`400`).

## What the app adjusts on its own

Phones come in different widths, and a message is narrower than the screen. So the app adapts your layout to keep it tidy:

- **Content gets room.** If a label doesn't fit in the given width, the app makes the element wider. If it then no longer fits in the row, it moves to the next one.
- **Rows are always full.** If space is left in a row, its elements get wider. A single element with `width: 3` therefore spans the full width.
- **Equal height.** Cards and buttons in a row are the same height. Text stays at the top left.
- **Charts** show only every second or third label when there are many points.

So your `width` is a wish, not a command. Two elements with `width: 3` and long labels often end up stacked in a message. Plan roughly and check the result on your phone.

## Tips

- Start without `width`. Everything stacked always looks tidy.
- Keep labels short, then two elements fit side by side.
- Three buttons with short labels, `width: 2` and `height: 56` make a row of tiles.
- A text with `style: "caption"` above a group works like a subheading.
- Ready-made examples to borrow from are in [Templates](https://packlets.app/en/docs/vorlagen.md).
