Phil Scott c2da268129
Docs redesign (#728)
* Adding a dark mode
* Adding reference for types to summary pages
* Adding API Reference
* Adding modifiers to methods/fields/etc
* Minimizing files input
* Caching a lot of the output pages
* Cache only for each execution
* Adding API references to existing docs
2022-02-14 18:44:25 +01:00

79 lines
1.8 KiB
Markdown

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.
Reference: T:Spectre.Console.Rule
---
The `Rule` class is used to render a horizontal rule (line) to the terminal.
<?# AsciiCast cast="rule" /?>
## Usage
To render a rule without a title:
```csharp
var rule = new Rule();
AnsiConsole.Write(rule);
```
## Title
You can set the rule title markup text.
```csharp
var rule = new Rule("[red]Hello[/]");
AnsiConsole.Write(rule);
```
```text
───────────────────────────────── Hello ─────────────────────────────────
```
## Title alignment
You can set the rule's title alignment.
```csharp
var rule = new Rule("[red]Hello[/]");
rule.Alignment = Justify.Left;
AnsiConsole.Write(rule);
```
```text
── Hello ────────────────────────────────────────────────────────────────
```
You can also specify it via an extension method:
```csharp
var rule = new Rule("[red]Hello[/]");
rule.LeftAligned();
AnsiConsole.Write(rule);
```
```text
── Hello ────────────────────────────────────────────────────────────────
```
## Styling
```csharp
var rule = new Rule("[red]Hello[/]");
rule.Style = Style.Parse("red dim");
AnsiConsole.Write(rule);
```
You can also specify it via an extension method
```csharp
var rule = new Rule("[red]Hello[/]");
rule.RuleStyle("red dim");
AnsiConsole.Write(rule);
```