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.8 KiB

Title: Rule Order: 30 RedirectFrom: rule Description: "The Rule class is used to render a horizontal rule (line) to the terminal." Highlights: - Custom colors for line and title. - Specify left, center or right aligned title.


The Rule class is used to render a horizontal rule (line) to the terminal.

Usage

To render a rule without a title:

var rule = new Rule();
AnsiConsole.Render(rule);

Title

You can set the rule title markup text.

var rule = new Rule("[red]Hello[/]");
AnsiConsole.Render(rule);
───────────────────────────────── Hello ─────────────────────────────────

Title alignment

You can set the rule's title alignment.

var rule = new Rule("[red]Hello[/]");
rule.Alignment = Justify.Left;
AnsiConsole.Render(rule);
── Hello ────────────────────────────────────────────────────────────────

You can also specify it via an extension method:

var rule = new Rule("[red]Hello[/]");
rule.LeftAligned();
AnsiConsole.Render(rule);
── Hello ────────────────────────────────────────────────────────────────

Styling

var rule = new Rule("[red]Hello[/]");
rule.Style = Style.Parse("red dim");
AnsiConsole.Render(rule);

You can also specify it via an extension method

var rule = new Rule("[red]Hello[/]");
rule.RuleStyle("red dim");
AnsiConsole.Render(rule);