Rows Widget

Stack multiple renderables vertically with consistent spacing

The Rows widget stacks multiple renderables vertically, creating organized layouts where each item appears on its own line.

Screenshot

When to Use

Use Rows when you need to arrange multiple widgets vertically in a single renderable unit. Common scenarios:

  • Multi-section layouts: Stack headers, content, and footers in a logical flow
  • Status dashboards: Organize different information panels vertically
  • Form-like displays: Present related information in a top-to-bottom sequence
  • Combining with other layouts: Create grid-like structures by nesting Rows within Columns

For horizontal arrangement, use Columns instead. For precise control over rows and columns with cell alignment, use Grid instead.

Basic Usage

Pass any collection of renderables to stack them vertically. Each item is rendered on a new line.

public static void BasicRowsExample()
{
    var rows = new Rows(
        new Markup("[blue]First row[/]"),
        new Markup("[green]Second row[/]"),
        new Markup("[yellow]Third row[/]"));
  
    AnsiConsole.Write(rows);
}

Stacking Widgets

Panels and Containers

Stack panels or other container widgets to create visually distinct sections.

public static void RowsPanelsExample()
{
    var rows = new Rows(
        new Panel("[blue]Header Section[/]").Header("Top"),
        new Panel("[green]Content Section[/]").Header("Middle"),
        new Panel("[yellow]Footer Section[/]").Header("Bottom"));
  
    AnsiConsole.Write(rows);
}

Mixed Content Types

Combine different widget types (tables, charts, rules) to build rich information displays.

public static void RowsMixedContentExample()
{
    var table = new Table()
        .AddColumn("Name")
        .AddColumn("Value")
        .AddRow("CPU", "45%")
        .AddRow("Memory", "78%");
  
    var chart = new BreakdownChart()
        .AddItem("Used", 78, Color.Red)
        .AddItem("Free", 22, Color.Green);
  
    var rows = new Rows(
        new Rule("[yellow]System Status[/]"),
        table,
        new Text(""),
        new Rule("[yellow]Disk Usage[/]"),
        chart);
  
    AnsiConsole.Write(rows);
}

Width Behavior

Use the Expand property to control whether rows fill the available console width or fit to their content. When Expand is false, each row's width matches its content.

public static void RowsExpandExample()
{
    AnsiConsole.MarkupLine("[yellow]Expand disabled (fit to content):[/]");
    var collapsed = new Rows(
        new Panel("Short"),
        new Panel("A longer panel with more text"))
    {
        Expand = false
    };
    AnsiConsole.Write(collapsed);
  
    AnsiConsole.WriteLine();
    AnsiConsole.MarkupLine("[yellow]Expand enabled (fill width):[/]");
    var expanded = new Rows(
        new Panel("Short"),
        new Panel("A longer panel with more text"))
    {
        Expand = true
    };
    AnsiConsole.Write(expanded);
}

Creating from Collections

Build rows dynamically from a collection of renderables, useful when the number of items varies.

public static void RowsFromCollectionExample()
{
    var items = new List<IRenderable>
    {
        new Markup("[red]Task 1: Initialize project[/]"),
        new Markup("[yellow]Task 2: Configure dependencies[/]"),
        new Markup("[green]Task 3: Run tests[/]"),
        new Markup("[blue]Task 4: Deploy application[/]")
    };
  
    var rows = new Rows(items);
    AnsiConsole.Write(rows);
}

Advanced Usage

Combining with Columns

Nest Rows and Columns to create complex grid-like layouts without using Grid's more verbose API.

public static void RowsWithColumnsExample()
{
    var topRow = new Columns(
        new Panel("[blue]Left Panel[/]").Header("Column 1"),
        new Panel("[green]Right Panel[/]").Header("Column 2"));
  
    var bottomRow = new Columns(
        new Panel("[yellow]Left Panel[/]").Header("Column 1"),
        new Panel("[red]Right Panel[/]").Header("Column 2"));
  
    var rows = new Rows(topRow, bottomRow);
    AnsiConsole.Write(rows);
}

Building Dashboards

Create multi-section status dashboards by stacking different types of information displays.

public static void RowsDashboardExample()
{
    var header = new Panel("[bold yellow]Application Dashboard[/]")
        .BorderColor(Color.Yellow)
        .Expand();
  
    var metrics = new Columns(
        new Panel("[green]Uptime: 99.9%[/]").Header("Availability"),
        new Panel("[blue]Response: 42ms[/]").Header("Performance"),
        new Panel("[purple]Active: 1,247[/]").Header("Users"));
  
    var logs = new Panel(
        "[grey]INFO[/]  Application started\n" +
        "[green]OK[/]    Health check passed\n" +
        "[yellow]WARN[/]  High memory usage")
        .Header("Recent Logs");
  
    var rows = new Rows(header, metrics, logs);
    AnsiConsole.Write(rows);
}

API Reference

Renders things in rows.

Constructors

Rows(IRenderable[] items)

Initializes a new instance of the class.

Parameters:

items (IRenderable[])
The items to render as rows.
Rows(IEnumerable<IRenderable> children)

Initializes a new instance of the class.

Parameters:

children (IEnumerable<IRenderable>)
The items to render as rows.

Properties

Expand : bool

Extension Methods

IEnumerable<Segment> GetSegments(IAnsiConsole console)

Gets the segments for a renderable using the specified console.

Parameters:

console (IAnsiConsole)
The console.

Returns:

An enumerable containing segments representing the specified .