Skip to content

Get-SpectreRenderableSize

Description

The Get-SpectreRenderableSize function gets the height of a Spectre Console renderable object. The width and height is estimated.
This method of size calculation is not perfect, but it is a good approximation for most use cases. There are factors outside of the control of this function that can affect the size of the widget once it’s rendered to the console.
The size of a containing object can influence the size of the widget when it’s expandable. If you know the width and height of a container that this widget will be rendered inside you can provide that as a parameter to get a more accurate size.


Examples

Example 1
This example calculates the height of a small panel

Terminal window
$panel = "hello`nworld" | Format-SpectrePanel
$panelSize = $panel | Get-SpectreRenderableSize
Write-SpectreHost "Panel width: $($panelSize.Width), height: $($panelSize.Height)"
$panel | Out-SpectreHost

Parameters

Renderable

TypeRequiredPositionPipelineInput
[Renderable]true1true (ByValue)

ContainerHeight

The height of the container that the widget will be rendered inside.

TypeRequiredPositionPipelineInput
[Int32]false2false

ContainerWidth

The width of the container that the widget will be rendered inside.

TypeRequiredPositionPipelineInput
[Int32]false3false

Syntax

Terminal window
Get-SpectreRenderableSize [-Renderable] <Renderable> [[-ContainerHeight] <Int32>] [[-ContainerWidth] <Int32>] [<CommonParameters>]