Skip to footer content
Iron Academy Logo
C# Application
C# Application

Other Categories

Adding Tables to Your Console - Spectre Console Series

Tim Corey
10m 24s

Spectre.Console is a powerful .NET library that helps you create beautiful console applications. Instead of plain text output, you can build structured layouts, use colors, and even show progress bars or interactive prompts. In his Spectre Console Series, Tim Corey shows developers how to get the most out of this library in small, practical lessons.

In his video, “Adding Tables to Your Console - Spectre Console Series”, Tim focuses on Spectre.Console tables. Tables are a core feature that let you display structured data with alignment, padding, borders, and styles. We’ll take a deeper look at Tim’s walkthrough so you can see exactly how to use this feature.

Getting Started with Spectre.Console

At the beginning (0:00), Tim explains that Spectre.Console enables you to create visually appealing, informative applications. It’s distributed as a NuGet package named Spectre.Console. You can install it easily with:

// dotnet add package spectre console
dotnet add package Spectre.Console
// dotnet add package spectre console
dotnet add package Spectre.Console

Once installed, the library makes it much easier to present information in a console application. Tim also points to the documentation and source code links provided with the video for anyone interested in further examples.

Creating Your First Table

Tim starts coding at 0:35. He creates a Table object:

var table = new Table();
var table = new Table();

He then adds three columns with AddColumn:

table.AddColumn("First Name");
table.AddColumn("Last Name");
table.AddColumn("Age");
table.AddColumn("First Name");
table.AddColumn("Last Name");
table.AddColumn("Age");

This creates the basic structure. He explains that each column can later have its own width, alignment, and style.

Next, he adds rows with AddRow. Tim at 1:06 says there are three supported ways to add rows:

  1. A params list of IRenderable objects (for nested items like a panel, another table, or even charts).

  2. A params list of strings (the most common).

  3. An IEnumerable(less common but available).

He demonstrates the second option first, adding:

table.AddRow("Tim", "Corey", "46");
table.AddRow("Sue", "Storm", "23");
table.AddRow("Tim", "Corey", "46");
table.AddRow("Sue", "Storm", "23");

This puts two rows of data into the table. At 3:26 Tim reminds viewers that you must use AnsiConsole.Write(table) (not WriteLine) to display an IRenderable like a table in the terminal:

AnsiConsole.Write(table);
AnsiConsole.Write(table);

When he runs the program, the console displays a neatly formatted table with the headers and rows aligned automatically. Even with only a few lines of code, Spectre makes the console output look much more professional.

Spectre Console Adding Tables 1 related to Creating Your First Table

Aligning and Expanding the Table

At 4:00, Tim shows how to control the table’s position on screen. For example:

table.Centered();
table.Centered();

This will display the entire table in the center of the console window. He explains that this setting affects the table as a whole, not the columns. You can also right-align or left-align the table. The default is left.

Spectre Console Adding Tables 2 related to Aligning and Expanding the Table

He then demonstrates table.Expand() at 5:01, which makes the table fill the entire width of the terminal window. Once expanded, centering has no effect because the table now takes up all available space. The default is a collapsed table.

Spectre Console Adding Tables 3 related to Aligning and Expanding the Table

Adding Borders and Understanding Terminal Support

Next, Tim adds a border at 5:21:

table.Border(TableBorder.Rounded);
table.Border(TableBorder.Rounded);

He runs the app inside Visual Studio’s console and notices the corners aren’t rounded. At 5:54, he switches to Windows Terminal and reruns it — now the rounded corners appear.

Tim explains (5:59) that the rendering capabilities depend on the terminal you’re using. The underlying shell just provides the output, but the terminal decides which styles it can show. Windows Terminal supports the rounded border characters; Visual Studio’s integrated console does not. The same applies to colors, markup, or any italic, underline, or bold text styles you might add.

He shows at 7:01 that even the Developer Command Prompt outside of Visual Studio renders correctly because it’s using a different terminal. This is an important point to keep in mind if you’re trying out Spectre features like progress bars, long running tasks, or tables: not all terminals can display every style.

Adding Row Separators

Tim also points out that you can show separators between rows for clarity:

table.ShowRowSeparators();
table.ShowRowSeparators();

This draws a horizontal line between each row, which can make information easier to scan in larger tables — especially when you’re building CLI tools that display lots of output or handle args dynamically.

Column-Level Styling: Padding, Width, Alignment

One of the strengths of Spectre.Console tables is how much you can customize each column individually. At 8:02, Tim modifies the first column:

table.Columns[0].PadLeft(5).PadRight(5);
table.Columns[0].PadLeft(5).PadRight(5);

This adds padding on both sides of the text. He then sets a fixed width on the second column:

table.Columns[1].Width(15);
table.Columns[1].Width(15);

Finally, he right-aligns that column’s content:

table.Columns[1].RightAligned();
table.Columns[1].RightAligned();

When he runs the program again at 9:10, you can see the first column padded, the second column set to a fixed width, and the content right-aligned. Even the header text respects these settings. Tim notes (8:42) that widths are measured in characters, not pixels.

These small touches — padding, alignment, and fixed widths — make your console applications much more readable. Combined with Spectre’s colors, markup, and panels, you can create output that feels closer to a GUI but runs entirely in a console.

Spectre Console Adding Tables 4 related to Column-Level Styling: Padding, Width, Alignment

Adding Rows from IEnumerable

At 9:25 Tim demonstrates the third way to add a row — by passing an IEnumerable. He prepares a list of Text objects:

var person = new List<Text>
{
    new Text("Bilbo"),
    new Text("Baggins"),
    new Text("111")
};

table.AddRow(person);
var person = new List<Text>
{
    new Text("Bilbo"),
    new Text("Baggins"),
    new Text("111")
};

table.AddRow(person);

This inserts another row using a collection. Tim comments that this option is “not terribly useful” in everyday code but it’s supported if you’re generating rows dynamically from another source, such as data from a file, a unit testing framework, or an interactive prompt.

Spectre Console Adding Tables 5 related to Adding Rows from IEnumerable

Wrapping Up

At the end of the video (9:59), Tim sums up: Spectre.Console tables give you a lot of power to present information in a neat and structured way. You can control the table’s alignment, width, and border style, add row separators, apply padding to columns, and even embed panels or other renderables.

Because the library is heavily inspired by modern CLI design, it supports not only tables but also progress indicators for long running tasks, charts, markup for bold, italic, underline, and colors (like blue or green text), and much more. Tim encourages viewers to check the documentation and try the examples to see how Spectre can make your console output more engaging.

By following Tim Corey’s step-by-step demonstration, you’ll see how Spectre.Console enables you to build beautiful console applications with minimal effort. Install the NuGet package, explore the API, and start transforming your plain console output into structured, styled displays today.

Hero Worlddot related to Adding Tables to Your Console - Spectre Console Series
Hero Affiliate related to Adding Tables to Your Console - Spectre Console Series

Earn More by Sharing What You Love

Do you create content for developers working with .NET, C#, Java, Python, or Node.js? Turn your expertise into extra income!