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.
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.

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.

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

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

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