Skip to content
ConsoleMonster
Cmdlet

New-ConsoleText

Module ConsoleMonster
Inputs
System.Object[]
Outputs
ConsoleMonster.Text.RichText

Creates rich text: multicolour words for table cells, calculated properties, titles, labels, log lines or output on its own.

Syntax

New-ConsoleText [-Alignment <Left|Center|Right>] [-BackgroundColor <Object[]>] [-Color <Object[]>] [-Gradient <Object[]>] [-Link <String>] [-Markup <String>] [-Plain] [-Role <ThemeToken>] [-Style <String[]>] [[-Text] <Object[]>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Creates rich text: multicolour words for table cells, calculated properties, titles, labels, log lines or output on its own.

-Text takes pieces that are shown literally (data is never interpreted); -Color and -BackgroundColor take one colour per piece, and pieces beyond the colours use the first colour, as Write-Color does. Colours are ConsoleColor names exactly as Write-Host shows them, theme roles (Pass, Fail, Warn, Info, Muted, Accent) that follow the light or dark theme, #RRGGBB, rgb(r,g,b) or r,g,b. -Markup adds Spectre-compatible markup ([bold lime]Ready[/]); -Style adds Bold, Dim, Italic, Underline, Strikethrough or Invert; -Link makes the text a hyperlink where the terminal supports it; -Gradient colours the text from one colour to another. The result works as a cell value (also from a calculated property), as the title or label of any widget, with Write-ConsoleLog and Update-ConsoleLane, and with Write-ConsoleWidget. Without colour (NO_COLOR, redirected output) the text stays plain.

Examples

Authored help example

EXAMPLE 1

New-ConsoleText -Alignment 'Value'

Parameters

-Alignment HorizontalAlignment optional
Alignment when the text is written as a widget: Left, Center or Right.
Possible values: Left, Center, Right
-BackgroundColor Object[] optionalaliases: B, BGC
Background colour per piece.
-Color Object[] optionalaliases: C, FGC, ForegroundColor
Foreground colour per piece: ConsoleColor names (PowerShell mapping), theme roles, #RRGGBB, rgb(r,g,b) or r,g,b.
-Gradient Object[] optional
Two colours: the text is coloured from the first to the second, per character.
A hyperlink target for the whole text (OSC 8 in Windows Terminal and VS Code, plain text elsewhere).
-Markup String optional
Markup added after the pieces ([bold lime]Ready[/] in [muted]3s[/]).
-Plain SwitchParameter optional
Kept for compatibility: text is literal by default; use -Markup for markup.
-Role ThemeToken optionalaliases: Token
A theme role for pieces without their own colour (Pass, Fail, Warn, Info, Muted, Accent...).
Possible values: Text, Muted, Subtle, Accent, Accent2, Pass, Fail, Warn, Info, Skip, Running, Pending, Border, Title, Header, Highlight, Surface, SurfaceAccent, Series1, Series2, Series3, Series4, Series5, Series6, Focus
-Style String[] optional
Decorations for the whole text: Bold, Dim, Italic, Underline, Strikethrough, Invert.
-Text Object[] optionalposition: 0pipeline: True (ByValue)aliases: T
The text pieces, shown literally (strings, or rich text from New-ConsoleText).

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.