mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-24 04:02:50 +08:00
Add documentation for rule
This commit is contained in:
parent
9afc1ea721
commit
037a215a78
BIN
docs/input/assets/images/rule.png
Normal file
BIN
docs/input/assets/images/rule.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.7 KiB |
71
docs/input/widgets/rule.md
Normal file
71
docs/input/widgets/rule.md
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
Title: Rule
|
||||||
|
Order: 5
|
||||||
|
RedirectFrom: rule
|
||||||
|
---
|
||||||
|
|
||||||
|
The `Rule` class is used to render a horizontal rule (line) to the terminal.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
To render a rule without a title:
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var rule = new Rule();
|
||||||
|
AnsiConsole.Render(rule);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Title
|
||||||
|
|
||||||
|
You can set the rule title markup text.
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var rule = new Rule("[red]Hello[/]");
|
||||||
|
AnsiConsole.Render(rule);
|
||||||
|
|
||||||
|
// output
|
||||||
|
───────────────────────────────── Hello ─────────────────────────────────
|
||||||
|
```
|
||||||
|
|
||||||
|
### Title alignment
|
||||||
|
|
||||||
|
You can set the rule's title alignment.
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var rule = new Rule("[red]Hello[/]");
|
||||||
|
rule.Alignment = Justify.Left;
|
||||||
|
AnsiConsole.Render(rule);
|
||||||
|
|
||||||
|
//output
|
||||||
|
── Hello ────────────────────────────────────────────────────────────────
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also specify it with a method
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var rule = new Rule("[red]Hello[/]");
|
||||||
|
rule.LeftAligned();
|
||||||
|
AnsiConsole.Render(rule);
|
||||||
|
|
||||||
|
//output
|
||||||
|
── Hello ────────────────────────────────────────────────────────────────
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Style
|
||||||
|
|
||||||
|
You can set the rule style.
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var rule = new Rule("[red]Hello[/]");
|
||||||
|
rule.Style = Style.Parse("red dim");
|
||||||
|
AnsiConsole.Render(rule);
|
||||||
|
```
|
||||||
|
You can also specify it with a method
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var rule = new Rule("[red]Hello[/]");
|
||||||
|
rule.SetStyle("red dim");
|
||||||
|
AnsiConsole.Render(rule);
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user