# Text does not fit in a diagram box: how to fix it

The message means a block's words need more width than the width you set, so open-diagram drew it wider than you asked.


```python
from open_diagram import Diagram, Panel


def build():
    d = Diagram("Parcel service")
    hub = d.add(Panel("Sorting hub", ["Scan parcels", "Weigh parcels"]), 0, 0, width=200)
    vans = d.right_of(hub, Panel("Vans", ["Morning round"]), width=200)
    d.link(hub, vans)
    return d

```

![Parcel service](https://open-diagram.dev/images/pages/problems-text-does-not-fit-1.svg)

The check: 1 layout problem(s)

```text
'Sorting hub' needs 253 px wide but was given 200; using 253
```


## Why does it happen?

A `width` given to `add()`, `right_of()` or `below()` can stretch a block, never shrink it. Every block measures its own words from the font before open-diagram places it.

Here the two blocks were meant to match at 200 px. The tiles in `Sorting hub` need 253 px, so it comes out 53 px wider than `Vans`.

In JSON, a panel's `width` also only widens it, but reports nothing, so this message comes from Python.

## How do I fix it?

Shorten the words, or give the block the width they need.

1. Shorten the words in the block's title or tiles. For longer detail, a tile can carry a second line in `sub`.
2. Or set `width` to the number the message names, or more.
3. Or leave `width` out, so each block takes the width its words need.
4. Run the check again.

Here the tile labels drop the word "parcels". Both blocks come out at 200 px, and the check reports 0 layout problems:


```python
from open_diagram import Diagram, Panel


def build():
    d = Diagram("Parcel service")
    hub = d.add(Panel("Sorting hub", ["Scan", "Weigh"]), 0, 0, width=200)
    vans = d.right_of(hub, Panel("Vans", ["Morning round"]), width=200)
    d.link(hub, vans)
    return d

```

![Parcel service](https://open-diagram.dev/images/pages/problems-text-does-not-fit-2.svg)

The check: 0 layout problems

Updated November 25, 2026. Web page: https://open-diagram.dev/problems/text-does-not-fit.html

See also:

- [Diagram text too small: how to fix it](https://open-diagram.dev/problems/text-too-small.md)
- [Diagram boxes too close or overlapping: how to fix it](https://open-diagram.dev/problems/boxes-too-close.md)
