# layout

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/tui/widgets/final_markdown/_layout/layout)

Lay out a whole reply.

Only top-level paragraphs get a bottom margin (`Markdown >
MarkdownParagraph`). `AssistantMessage` sets `margin-bottom: 0` on the
last block so a reply has no trailing blank row. In Textual that rule
replaces the whole margin, so the last block loses its top margin too.

## Signature

```python
layout(
    nodes: list[Node],
    width: int,
    theme: Theme,
) -> list[Row]
```

## Returns

`list[Row]`

The reply's rows.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/1425cf0b7c5e88bff8735778af82cf5c90564085/libs/code/deepagents_code/tui/widgets/final_markdown/_layout.py#L270)