Phil Scott 223642b797
Add blog to docs (#484)
* Adding social card infrastructure
* Upgrades doc project to .NET 6
* Adds Playwright
* Changes the console to a web project for Playwright
* Adds social card template
* Added blog content
* Parallelized social image processing
* Updating CI to use .NET 6 for docs build
2021-07-15 19:53:01 +02:00

1.3 KiB

Title: Tree Order: 10 Description: "The Tree widget can be used to render hierarchical data." Highlights: - Custom colors and styles for guidelines. - Include any Spectre.Console widgets as child nodes.

The Tree widget can be used to render hierarchical data.

Usage

// Create the tree
var root = new Tree("Root");

// Add some nodes
var foo = root.AddNode("[yellow]Foo[/]");
var table = foo.AddNode(new Table()
    .RoundedBorder()
    .AddColumn("First")
    .AddColumn("Second")
    .AddRow("1", "2")
    .AddRow("3", "4")
    .AddRow("5", "6"));

table.AddNode("[blue]Baz[/]");
foo.AddNode("Qux");

var bar = root.AddNode("[yellow]Bar[/]");
bar.AddNode(new Calendar(2020, 12)
    .AddCalendarEvent(2020, 12, 12)
    .HideHeader());

// Render the tree
AnsiConsole.Render(root);

Collapsing nodes

root.AddNode("Label").Collapsed();

Appearance

Style

var root = new Tree("Root")
    .Style("white on red");

Guide lines

// ASCII guide lines
var root = new Tree("Root")
    .Guide(TreeGuide.Ascii);

// Default guide lines
var root = new Tree("Root")
    .Guide(TreeGuide.Line);

// Double guide lines
var root = new Tree("Root")
    .Guide(TreeGuide.DoubleLine);

// Bold guide lines
var root = new Tree("Root")
    .Guide(TreeGuide.BoldLine);