mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-15 00:12:50 +08:00
Added documentation for Rows widget
This commit is contained in:
parent
9df6ed213c
commit
2a493cfee9
0
docs/Preview.ps1
Normal file → Executable file
0
docs/Preview.ps1
Normal file → Executable file
2
docs/input/assets/casts/rows-rich.cast
Normal file
2
docs/input/assets/casts/rows-rich.cast
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
{"version": 2, "width": 50, "height": 5, "timestamp": 1667278514, "env": {"SHELL": "/bin/bash", "TERM": "xterm-256color"}}
|
||||||
|
[0, "o", "\u001b[38;5;9;48;5;0mItem 1\u001b[0m\r\n\u001b[38;5;2;48;5;0mItem 2\u001b[0m\r\n\u001b[38;5;12;48;5;0mItem 3\u001b[0m\r\n"]
|
54
docs/input/widgets/rows.md
Normal file
54
docs/input/widgets/rows.md
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
Title: Rows
|
||||||
|
Order: 20
|
||||||
|
Description: "Use **Rows** to render widgets in horiztonal rows to the console."
|
||||||
|
Highlights:
|
||||||
|
- Custom colors
|
||||||
|
- Labels
|
||||||
|
- Use your own data with a converter.
|
||||||
|
Reference: T:Spectre.Console.Rows
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Use `Rows` to render widgets in horizontal rows to the console.
|
||||||
|
|
||||||
|
<?# AsciiCast cast="rows" /?>
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Basic usage
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
// Render two items on separate rows to Console
|
||||||
|
AnsiConsole.Write(new Rows(
|
||||||
|
new Text("Item 1"),
|
||||||
|
new Text("Item 2")
|
||||||
|
));
|
||||||
|
```
|
||||||
|
|
||||||
|
### Add items from an IEnumerable
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
// Create a list of Items
|
||||||
|
var rows = new List<Text>(){
|
||||||
|
new Text("Item 1"),
|
||||||
|
new Text("Item 2"),
|
||||||
|
new Text("Item 3")
|
||||||
|
};
|
||||||
|
|
||||||
|
// Render each item in list on separate line
|
||||||
|
AnsiConsole.Write(new Rows(rows));
|
||||||
|
```
|
||||||
|
|
||||||
|
### Apply custom styles to each row
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
// Create a list of Items, apply separate styles to each
|
||||||
|
var rows = new List<Text>(){
|
||||||
|
new Text("Item 1", new Style(Color.Red, Color.Black)),
|
||||||
|
new Text("Item 2", new Style(Color.Green, Color.Black)),
|
||||||
|
new Text("Item 3", new Style(Color.Blue, Color.Black))
|
||||||
|
};
|
||||||
|
|
||||||
|
// Renders each item with own style
|
||||||
|
AnsiConsole.Write(new Rows(rows));
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user