Skip to content

Format-SpectrePanel

Description

This function takes a string and formats it as a Spectre Console panel with optional title, border, and color. The resulting panel can be displayed in the console using the Write-Host command.
This function takes a string or renderable object and formats it as a Spectre Console panel with optional title, border, and color. The resulting panel can be displayed in the console using the Write-Host command.

See https://spectreconsole.net/widgets/panel for more information.


Examples

Example 1
This example demonstrates how to display a panel with a title and a rounded border.

Terminal window
Format-SpectrePanel -Data "Hello, world!" -Title "My Panel" -Border "Rounded" -Color "Red"

Example 2
This example demonstrates how to display a panel with a title and a double border that’s expanded to take up the whole console width.

Terminal window
"Hello, big panel!" | Format-SpectrePanel -Title "My Big Panel" -Border "Double" -Color "Magenta1" -Expand

Example 3
This example demonstrates how to combine text and images in a single panel. When combining multiple items in a panel, use Format-SpectreRows or Format-SpectreColumns to wrap them into a single renderable object.

Terminal window
$message = "Thanks Jeff!"
$image = Get-SpectreImage -ImagePath ".\private\images\smiley.png" -MaxWidth 25
@($message, $image) | Format-SpectreRows | Format-SpectrePanel

Example 4
This example demonstrates how to combine text and images in a single panel with side-by-side layout.

Terminal window
$message = "Thanks Jeff!"
$image = Get-SpectreImage -ImagePath ".\private\images\smiley.png" -MaxWidth 25
@($message, $image) | Format-SpectreColumns | Format-SpectrePanel

Parameters

Data

The renderable item to be formatted as a panel.

TypeRequiredPositionPipelineInput
[Object]true1true (ByValue)

The title to be displayed at the top of the panel.

TypeRequiredPositionPipelineInputAliases
[String]false2falseTitle

Border

The type of border to be displayed around the panel.

Valid Values:

  • Ascii
  • Double
  • Heavy
  • None
  • Rounded
  • Square
TypeRequiredPositionPipelineInput
[String]false3false

Expand

Switch parameter that specifies whether the panel should be expanded to fill the available space.

TypeRequiredPositionPipelineInput
[Switch]falsenamedfalse

Color

The color of the panel border.

TypeRequiredPositionPipelineInput
[Color]false4false

Width

The width of the panel.

TypeRequiredPositionPipelineInput
[Int32]false5false

Height

The height of the panel.

TypeRequiredPositionPipelineInput
[Int32]false6false

Syntax

Terminal window
Format-SpectrePanel [-Data] <Object> [[-Header] <String>] [[-Border] <String>] [-Expand] [[-Color] <Color>] [[-Width] <Int32>] [[-Height] <Int32>] [<CommonParameters>]