Padder
IPadder wraps a child renderable and adds whitespace around it - useful when you want spacing without a Panel's border.
When to use
- Visually separating content blocks without drawing a border.
- Indenting a block of output relative to its surroundings.
- Adjusting spacing inside a panel that doesn't carry enough internal padding by itself.
Basic usage
pascal
AnsiConsole.Write(
Widgets.Padder(Widgets.Markup('[bold]content[/]'))
.WithPadding(TPadding.Create(2, 1, 2, 1))); // left, top, right, bottom1
2
3
2
3
Configuration
| Method | Purpose |
|---|---|
WithPadding(value : TPadding) | Set padding on all four sides via a TPadding record. |
The TPadding record's constructor takes (left, top, right, bottom) cell counts. Build one inline:
pascal
panel := Widgets.Padder(content).WithPadding(TPadding.Create(4, 0, 4, 0));1
A symmetric padding factory may also be useful:
pascal
TPadding.Symmetric(2) // 2 cells on every side
TPadding.Create(0, 1, 0, 1) // 1 cell top + bottom only1
2
2
Composition
Padder is often used to indent a paragraph or block:
pascal
AnsiConsole.Write(Widgets.Padder(longParagraph)
.WithPadding(TPadding.Create(4, 0, 0, 0)));1
2
2
Or to add breathing room around a chart inside a panel:
pascal
AnsiConsole.Write(
Widgets.Panel(
Widgets.Padder(barChart).WithPadding(TPadding.Create(1, 0, 1, 0)))
.WithHeader('Chart'));1
2
3
4
2
3
4
API reference
Widgets.Padder(child)— wraps anyIRenderable.IPadder— interface.