diff --git a/docs/input/assets/casts/padder-rich.cast b/docs/input/assets/casts/padder-rich.cast new file mode 100644 index 0000000..0988b4c --- /dev/null +++ b/docs/input/assets/casts/padder-rich.cast @@ -0,0 +1,2 @@ +{"version": 2, "width": 40, "height": 6, "timestamp": 1667448519, "env": {"SHELL": "/bin/bash", "TERM": "xterm-256color"}} +[0.0, "o", " \r\n \u001b[38;5;9;48;5;0mPadded Text I\u001b[0m \u001b[38;5;12;48;5;0mPadded Text II\u001b[0m \r\n \r\n"] diff --git a/docs/input/widgets/padder.md b/docs/input/widgets/padder.md new file mode 100644 index 0000000..d63bc54 --- /dev/null +++ b/docs/input/widgets/padder.md @@ -0,0 +1,68 @@ +Title: Padder +Order: 55 +Description: "Use **Padder** to add padding around a Widget." +Highlights: + - Custom colors + - Labels + - Use your own data with a converter. +Reference: T:Spectre.Console.Padder + +--- + +Use `Padder` to add padding around a Widget. + + + +## Usage + +### Basic usage + +```csharp +// Create three text elements +var paddedText_I = new Text("Padded Text I", new Style(Color.Red, Color.Black)); +var paddedText_II = new Text("Padded Text II", new Style(Color.Green, Color.Black)); +var paddedText_III = new Text("Padded Text III", new Style(Color.Blue, Color.Black)); + +// Apply padding to the three text elements +var pad_I = new Padder(paddedText_I).PadRight(16).PadBottom(0).PadTop(4); +var pad_II = new Padder(paddedText_II).PadBottom(0).PadTop(2); +var pad_III = new Padder(paddedText_III).PadLeft(16).PadBottom(0).PadTop(0); + +// Insert padded elements within single-row grid +var grid = new Grid(); + +grid.AddColumn(); +grid.AddColumn(); +grid.AddColumn(); + +grid.AddRow(pad_I, pad_II, pad_III); + +// Write grid and it's padded contents to the Console +AnsiConsole.Write(grid); +``` + +### Padding element within a padded element + +```csharp +// Create two text elements +var paddedText_I = new Text("Padded Text I", new Style(Color.Red, Color.Black)); +var paddedText_II = new Text("Padded Text II", new Style(Color.Blue, Color.Black)); + +// Create, apply padding on text elements +var pad_I = new Padder(paddedText_I).PadRight(2).PadBottom(0).PadTop(0); +var pad_II = new Padder(paddedText_II).PadLeft(2).PadBottom(0).PadTop(0); + +// Insert the text elements into a single row grid +var grid = new Grid(); + +grid.AddColumn(); +grid.AddColumn(); + +grid.AddRow(pad_I, pad_II); + +// Apply horizontal and vertical padding on the grid +var paddedGrid = new Padder(grid).Padding(4,1); + +// Write the padded grid to the Console +AnsiConsole.Write(paddedGrid); +``` \ No newline at end of file