A theme restyles every widget at once. Widgets never name colours directly; they use theme roles such as Pass, Muted and Accent, and a theme maps each role to a 24-bit colour with its 256 and 16-colour fallbacks, so a role stays distinguishable on every tier. The full list of roles is below.
╭─ Nightly checks ─────── lab01.contoso.com ─╮ │ ✓ Discover › ✓ Collect › ⠋ Evaluate │ │ 2.1s 14s 64% │ │ █████████████████████████████████████ 500 │ │ █ ✓ Passed 412 82% │ │ █ ▲ Warnings 51 10% │ │ █ ✗ Failed 23 5% │ │ █ – Skipped 14 3% │ │ rules/s ▃▃▃▃▄▄▄▄▅▅▅▆▅▆▇▆▇▇▇█ 57/s │ ╰────────────────────────────────────────────╯
╭─ Nightly checks ─────── lab01.contoso.com ─╮ │ ✓ Discover › ✓ Collect › ⠋ Evaluate │ │ 2.1s 14s 64% │ │ █████████████████████████████████████ 500 │ │ █ ✓ Passed 412 82% │ │ █ ▲ Warnings 51 10% │ │ █ ✗ Failed 23 5% │ │ █ – Skipped 14 3% │ │ rules/s ▃▃▃▃▄▄▄▄▅▅▅▆▅▆▇▆▇▇▇█ 57/s │ ╰────────────────────────────────────────────╯
╭─ Nightly checks ─────── lab01.contoso.com ─╮ │ ✓ Discover › ✓ Collect › ⠋ Evaluate │ │ 2.1s 14s 64% │ │ █████████████████████████████████████ 500 │ │ █ ✓ Passed 412 82% │ │ █ ▲ Warnings 51 10% │ │ █ ✗ Failed 23 5% │ │ █ – Skipped 14 3% │ │ rules/s ▃▃▃▃▄▄▄▄▅▅▅▆▅▆▇▆▇▇▇█ 57/s │ ╰────────────────────────────────────────────╯
$rate = 18, 21, 19, 24, 27, 26, 31, 29, 34, 38, 36, 41, 39, 44, 47, 45, 50, 48, 53, 57
New-ConsolePanel -Title '[bold]Nightly checks[/]' -HeaderRight 'lab01.contoso.com' -Content {
New-ConsoleRows -Content {
New-ConsoleStatusList -Layout Strip -WidgetId phases -Content {
[pscustomobject] @{ Key = 'Discover'; Label = 'Discover'; Status = 'Pass'
Detail = '2.1s' }
[pscustomobject] @{ Key = 'Collect'; Label = 'Collect'; Status = 'Pass'
Detail = '14s' }
[pscustomobject] @{ Key = 'Evaluate'; Label = 'Evaluate'; Status = 'Running'
Detail = '64%' }
}
New-ConsoleChart -Type Stacked -Content {
[pscustomobject] @{ Label = 'Passed'; Value = 412; Role = 'Pass' }
[pscustomobject] @{ Label = 'Warnings'; Value = 51; Role = 'Warn' }
[pscustomobject] @{ Label = 'Failed'; Value = 23; Role = 'Fail' }
[pscustomobject] @{ Label = 'Skipped'; Value = 14; Role = 'Skip' }
}
New-ConsoleChart -Type Sparkline -Title 'rules/s' -Unit '/s' -InputObject $rate
}
} | Show-ConsoleFull program
Import-Module ConsoleMonster
$rate = 18, 21, 19, 24, 27, 26, 31, 29, 34, 38, 36, 41, 39, 44, 47, 45, 50, 48, 53, 57
New-ConsolePanel -Title '[bold]Nightly checks[/]' -HeaderRight 'lab01.contoso.com' -Content {
New-ConsoleRows -Content {
New-ConsoleStatusList -Layout Strip -WidgetId phases -Content {
[pscustomobject] @{ Key = 'Discover'; Label = 'Discover'; Status = 'Pass'
Detail = '2.1s' }
[pscustomobject] @{ Key = 'Collect'; Label = 'Collect'; Status = 'Pass'
Detail = '14s' }
[pscustomobject] @{ Key = 'Evaluate'; Label = 'Evaluate'; Status = 'Running'
Detail = '64%' }
}
New-ConsoleChart -Type Stacked -Content {
[pscustomobject] @{ Label = 'Passed'; Value = 412; Role = 'Pass' }
[pscustomobject] @{ Label = 'Warnings'; Value = 51; Role = 'Warn' }
[pscustomobject] @{ Label = 'Failed'; Value = 23; Role = 'Fail' }
[pscustomobject] @{ Label = 'Skipped'; Value = 14; Role = 'Skip' }
}
New-ConsoleChart -Type Sparkline -Title 'rules/s' -Unit '/s' -InputObject $rate
}
} | Show-Console// One assessment summary: phases, results as a stacked bar and the rule rate as a sparkline, in a panel.
double[] rate = { 18, 21, 19, 24, 27, 26, 31, 29, 34, 38, 36, 41, 39, 44, 47, 45, 50, 48, 53, 57 };
Terminal.Write(new Panel(
new Rows()
.Add(new Phases()
.Set("Discover", StatusKind.Pass, default, "2.1s")
.Set("Collect", StatusKind.Pass, default, "14s")
.Set("Evaluate", StatusKind.Running, default, "64%"))
.Add(new StackedBar()
.Add("Passed", 412, ThemeToken.Pass)
.Add("Warnings", 51, ThemeToken.Warn)
.Add("Failed", 23, ThemeToken.Fail)
.Add("Skipped", 14, ThemeToken.Skip))
.Add(new Sparkline() { Title = "rules/s", Unit = "/s" }.Values(rate)),
"[bold]Nightly checks[/]") { HeaderRight = "lab01.contoso.com" });Full program
using ConsoleMonster;
using ConsoleMonster.Layout;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;
// One assessment summary: phases, results as a stacked bar and the rule rate as a sparkline, in a panel.
double[] rate = { 18, 21, 19, 24, 27, 26, 31, 29, 34, 38, 36, 41, 39, 44, 47, 45, 50, 48, 53, 57 };
Terminal.Write(new Panel(
new Rows()
.Add(new Phases()
.Set("Discover", StatusKind.Pass, default, "2.1s")
.Set("Collect", StatusKind.Pass, default, "14s")
.Set("Evaluate", StatusKind.Running, default, "64%"))
.Add(new StackedBar()
.Add("Passed", 412, ThemeToken.Pass)
.Add("Warnings", 51, ThemeToken.Warn)
.Add("Failed", 23, ThemeToken.Fail)
.Add("Skipped", 14, ThemeToken.Skip))
.Add(new Sparkline() { Title = "rules/s", Unit = "/s" }.Values(rate)),
"[bold]Nightly checks[/]") { HeaderRight = "lab01.contoso.com" });// One assessment summary: phases, results as a stacked bar and the rule rate as a sparkline, in a panel.
double[] rate = { 18, 21, 19, 24, 27, 26, 31, 29, 34, 38, 36, 41, 39, 44, 47, 45, 50, 48, 53, 57 };
Ui.Panel().Title("[bold]Nightly checks[/]").HeaderRight("lab01.contoso.com").Content(panelContent =>
{
panelContent.Rows(r => r.Add(Ui.Phases()
.Set("Discover", StatusKind.Pass, default, "2.1s")
.Set("Collect", StatusKind.Pass, default, "14s")
.Set("Evaluate", StatusKind.Running, default, "64%"))
.Add(Ui.StackedBar()
.Add("Passed", 412, ThemeToken.Pass)
.Add("Warnings", 51, ThemeToken.Warn)
.Add("Failed", 23, ThemeToken.Fail)
.Add("Skipped", 14, ThemeToken.Skip))
.Add(Ui.Sparkline().Title("rules/s").Unit("/s").Values(rate)));
}).Show();
Full program
using ConsoleMonster;
using ConsoleMonster.Layout;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;
// One assessment summary: phases, results as a stacked bar and the rule rate as a sparkline, in a panel.
double[] rate = { 18, 21, 19, 24, 27, 26, 31, 29, 34, 38, 36, 41, 39, 44, 47, 45, 50, 48, 53, 57 };
Ui.Panel().Title("[bold]Nightly checks[/]").HeaderRight("lab01.contoso.com").Content(panelContent =>
{
panelContent.Rows(r => r.Add(Ui.Phases()
.Set("Discover", StatusKind.Pass, default, "2.1s")
.Set("Collect", StatusKind.Pass, default, "14s")
.Set("Evaluate", StatusKind.Running, default, "64%"))
.Add(Ui.StackedBar()
.Add("Passed", 412, ThemeToken.Pass)
.Add("Warnings", 51, ThemeToken.Warn)
.Add("Failed", 23, ThemeToken.Fail)
.Add("Skipped", 14, ThemeToken.Skip))
.Add(Ui.Sparkline().Title("rules/s").Unit("/s").Values(rate)));
}).Show();
Theme.Dark, Theme.Light and Theme.HighContrast.Choosing the theme
Show-ConsoleSetting, orSet-ConsoleSetting Theme ... -Save, for every session (below).CONSOLEMONSTER_THEME=light|dark|auto(defaultauto), orTerminalProfile.WithThemeMode(andWithPalette) in code.autoreads the console background colour in conhost. In Windows Terminal, which does not report its scheme to console programs,autopicks the dark theme; setCONSOLEMONSTER_THEME=lightfor a light scheme.Set-ConsoleThemein PowerShell,LiveSessionOptions.Themefor one session.
To switch for the rest of the session in PowerShell, or for every write that follows in C#:
Import-Module ConsoleMonster
Set-ConsoleTheme Light
Write-ConsoleText -Markup '[pass]√ 412 passed[/] [warn]▲ 51 warnings[/] [fail]✗ 23 failed[/]'
using ConsoleMonster;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;
Terminal.Theme = Theme.Light; // every write from here on
Terminal.Write(TextBlock.FromMarkup("[pass]√ 412 passed[/] [warn]▲ 51 warnings[/] [fail]✗ 23 failed[/]"));
Terminal.Theme = Theme.HighContrast;
Terminal.Write(new Rule("[bold]High contrast[/]"));
using ConsoleMonster;
using ConsoleMonster.Styling;
Terminal.Theme = Theme.Light; // every write from here on
Ui.Markup("[pass]√ 412 passed[/] [warn]▲ 51 warnings[/] [fail]✗ 23 failed[/]").Show();
Terminal.Theme = Theme.HighContrast;
Ui.Rule("[bold]High contrast[/]").Show();
Follow your terminal
Choose Terminal (follow my terminal) in the Theme list in Show-ConsoleSetting, or use:
Set-ConsoleTheme Terminal -Save
Test-ConsoleTheme -Theme Terminal
Export-ConsoleTheme -Path ./terminal-theme.json
Terminal keeps ANSI palette indexes even at true-colour depth, so your terminal application chooses the colours. Before ConsoleMonster opens the keyboard, it asks for the sixteen colours with OSC 4 and the default foreground and background with OSC 10/11. Each guarded exchange has a 100 ms timeout and runs only in an interactive Unix terminal, never with redirected input/output or in CI. Terminal.Palette contains the result, or null when it is unavailable. The probe cannot run after another ConsoleMonster input reader has started.
Exports and recordings use the measured RGB palette when available. Otherwise they use the background variant's default colours; the capability decisions record that fallback. An unavailable palette leaves colour checks Unknown. Auto continues choosing the built-in light or dark theme from the detected background.
Import a colour scheme
The colour scheme gallery shows Dracula, Nord, Solarized, Gruvbox, Catppuccin and Tokyo Night, each faithful and accessible, with what the checker says about it. Any other scheme can be imported from its file:
Import-ConsoleTheme -Path ./my-scheme.json -OutFile ./my-theme.json
Set-ConsoleTheme -Path ./my-theme.json
Import-ConsoleTheme -Path ./my-scheme.itermcolors -Accessible -OutFile ./my-accessible-theme.json
Set-ConsoleTheme -Path ./my-accessible-theme.json
Import accepts a single Windows Terminal scheme object (or settings.json containing one schemes entry), an XML iTerm2 .itermcolors plist in sRGB, or a flat base16 .yaml/.yml scheme. Without -OutFile, it writes <source-name>.theme.json beside the source. It reports the same verdict as Test-ConsoleTheme and imports even when checks fail. Import does not change the active theme.
A faithful theme chooses colours from the palette unchanged, preferring a normal or bright candidate with 3:1 contrast while keeping the role's hue; grey bright slots do not replace coloured statuses. Gap uses the muted text colour. The accessible variant first chooses status colours from that palette, then adjusts OKLCH lightness while retaining hue and at least half the source chroma. If that hue cannot meet the bars, it tries another palette colour in the same family: blue-to-cyan, orange-to-yellow or red-to-magenta. Fail is also underlined. The report lists the roles adjusted for contrast. Arbitrary imported palettes may still fall short; the report gives the measurements. A version 3 file keeps the embedded scheme, so it can also be selected with Set-ConsoleTheme -Path ./my-theme.json -Accessible -Save without rewriting the source file.
In C#, use TerminalScheme.Load(path) and Theme.FromScheme(scheme, accessible: true). See theme files for role overrides and checking themes for measurements.
Keep a theme for every session
Show-ConsoleSetting opens a picker with a preview that redraws as you move through the themes, glyph sets, colour depths and the other settings, so you can compare them before choosing. Save keeps the choices for every session; Escape leaves everything as it was. Without the picker, -Save does the same:
Set-ConsoleTheme ColorBlindSafe -Save # or: Set-ConsoleSetting Theme ColorBlindSafe -Save
Set-ConsoleSetting Glyphs Basic -Save
Get-ConsoleSetting # each setting, its value and where it came from
Saved settings go to settings.json in %APPDATA%\ConsoleMonster on Windows and ~/.config/ConsoleMonster on macOS and Linux. Every PowerShell session and every program built on ConsoleMonster reads it, so nothing needs to go in your profile. A theme can also be the path of a team theme file.
The strongest choice wins: a theme passed to one call, then Set-ConsoleSetting or Set-ConsoleTheme in this session, then a CONSOLEMONSTER_* environment variable, then the settings file, then detection. Variables beat the file, so CI and one-off runs keep working without touching it, and CONSOLEMONSTER_SETTINGS=none ignores the file. In C#, ConsoleSettings.Current lists the effective values with their sources, and ConsoleSettings.FilePath = null keeps a program's output fixed whatever the user saved.
The light theme meets WCAG contrast on white, and the dark theme keeps titles readable on a light background that could not be detected, because titles, headers and highlights use the terminal's own foreground in bold.
Frames and status words
A theme is more than colours. Its style picks the frame drawn around panels, tables and inputs, and whether statuses show as symbols (✓ ✗ ▲) or as words ([OK] [FAIL] [WARN]). Words help screen readers and anyone who finds small symbols hard to tell apart, and they look the same in every terminal font. Keep your own style whatever the theme:
Set-ConsoleSetting Border Single -Save
Set-ConsoleSetting Density Compact -Save
Set-ConsoleSetting StatusMarkers Words -Save
Show-ConsoleSetting previews these choices. A widget that asks for its own frame (New-ConsolePanel -Border Double) keeps it, and the ASCII glyph tier still draws ASCII. CONSOLEMONSTER_BORDER, CONSOLEMONSTER_DENSITY and CONSOLEMONSTER_STATUS_MARKERS set them for one run; in C#, Theme.WithAppearance gives a theme its style and TerminalProfile.WithBorder and WithDensity and WithStatusMarkers override it.
Comfortable is the default spacing. Compact removes boxed table cell padding, reduces unboxed table and list gaps from two cells to one, removes default horizontal panel padding, and closes the default gap between framed layout tiles. Unframed children keep at least one cell of default separation; larger default gaps shrink by one. Explicit padding, gaps and column gaps keep the values the author set. In C#, use new ThemeAppearance(ThemeDensity.Compact) with Theme.WithAppearance, or profile.WithDensity(ThemeDensity.Compact) for an override.
Exports follow your choice too: once you pick a theme, Export-ConsoleFrame draws in it on the background it is made for. -Theme Auto still gives both the dark and the light rendering, and -Theme Current asks for the theme in use.
Roles and markup
Every role is also a markup tag, written in lower case ([pass]OK[/], [muted]12:00[/]), and works as a background too ([white on fail]). In PowerShell, -Role on New-ConsoleText and Write-ConsoleText takes the same names; in C#, the roles are the ThemeToken values. Theme files call them tokens. Without colour, a status role adds its symbol, so status is never shown by colour alone.
| Role | Used for | Markup tag |
|---|---|---|
Text | Body text | [text] |
Muted | Secondary text: timestamps, units, hints | [muted] |
Subtle | Very low emphasis: empty bar tracks, guides, separators | [subtle] |
Accent | The primary accent: titles, active items, the main series | [accent] |
Accent2 | A secondary accent hue | [accent2] |
Pass | Success, passed | [pass] |
Fail | Failure, error | [fail] |
Warn | Warning | [warn] |
Info | Informational | [info] |
Skip | Skipped, not applicable | [skip] |
Running | In progress | [running] |
Pending | Queued, not started | [pending] |
Border | Panel and table borders | [border] |
Title | Panel titles | [title] |
Header | Table and section headers | [header] |
Highlight | Emphasised values, key figures | [highlight] |
Surface | Header and footer bars; carries a background | [surface] |
SurfaceAccent | Accent text on Surface | [surfaceaccent] |
Series1 to Series6 | Chart series one to six | [series1] to [series6] |
Focus | The focused row or control in prompts, menus and forms; carries a background | [focus] |
Strong | Emphasised text without a background fill | [strong] |
Low | A low-severity finding | [low] |
Critical | A critical finding, always emphasised | [critical] |
Gap | An evidence gap that prevented evaluation | [gap] |
Reduction per tier
Colours given as hex, rgb() or palette names are reduced for each tier the way the SGR encoder sends them: to the nearest of the 256 xterm colours on a 256-colour console, and to the nearest of the 16 console colours on a 16-colour one. Theme roles use the 256 and 16-colour values the theme defines instead of the nearest match. The widget gallery shows every widget at each tier.
Share a team theme file
Export a starting palette, edit its roles (the Tokens in the file) and load it for the session:
Import-Module ConsoleMonster
Set-ConsoleTheme -Theme Dark
Export-ConsoleTheme -Path ./team-theme.json -PassThru
# Edit the file, then apply it.
Set-ConsoleTheme -Path ./team-theme.json
Write-ConsoleText 'Deployment ready' -Role Pass
Choose Dark, Light, HighContrast or ColorBlindSafe with -Theme. ColorBlindSafe keeps pass, warning and fail distinct with red-green colour blindness (blue, yellow and underlined rose) and switches to its light variant when it detects a light background (otherwise it stays dark); ColorBlindSafeLight and ColorBlindSafeDark pick one explicitly. Status widgets retain their symbols and words. To keep the theme, or the team file, in every session, add -Save (Set-ConsoleTheme -Path ./team-theme.json -Save). Export any preset as a starting file. Changing the widget theme does not change the terminal application's background.
Use .psd1 instead of .json for a restricted PowerShell data file. The extension selects the format. Export replaces an existing destination, whose parent folder must exist; -WhatIf previews the write and -PassThru returns its FileInfo. Export does not change the active theme. Invalid files raise an error and leave the previous theme active.
A partial JSON file can inherit from a built-in palette. Save this as team-theme.json to change the accent while keeping the other Dark roles:
{
"SchemaVersion": 1,
"Name": "Team Dark",
"BaseTheme": "Dark",
"Tokens": {
"Accent": {
"Foreground": { "TrueColor": "#7dd3fc", "Ansi16": 14, "Ansi256": 117 },
"Decoration": "Bold"
}
}
}
Name and Tokens are required; SchemaVersion defaults to 1. With "SchemaVersion": 2 a file can also set its style: "Style": { "Border": "Single", "Density": "Compact", "StatusMarkers": "Words", "Background": "Dark" }. Missing tokens and style fields inherit from BaseTheme. Styles accept Foreground, Background and Decoration. Explicit null colours use terminal defaults; "Decoration": "None" clears inherited decoration. Fallback indices use ANSI palette order: Ansi16 is 0–15 (-1 uses the terminal default), while Ansi256 is 0–255 (-1 requests automatic reduction). Complete exports resolve inheritance and include every token. Unknown keys, tokens and invalid values are rejected before application.
Try it: the same report before and after
Save team-dark.json and team-light.json next to the program. The script builds a status list, a table and a log with native PowerShell cmdlets, then draws the same widgets with the built-in palette and with the team file.
Install-Module ConsoleMonster -Scope CurrentUser# … 24 lines of help in the full program
[CmdletBinding()]
param(
[ValidateSet('Dark', 'Light')]
[string] $BaseTheme = 'Dark',
[string] $Path,
[ValidateRange(40, 240)]
[int] $Width = 120,
[string] $ExportDirectory
)
Import-Module ConsoleMonster -ErrorAction Stop
if (-not $Path) {
$Path = Join-Path $PSScriptRoot ('team-' + $BaseTheme.ToLowerInvariant() + '.json')
}
if ($ExportDirectory) {
$null = New-Item -ItemType Directory -Path $ExportDirectory -Force
$presets = 'Dark', 'Light', 'HighContrast', 'ColorBlindSafeDark', 'ColorBlindSafeLight'
foreach ($preset in $presets) {
Set-ConsoleTheme -Theme $preset
Export-ConsoleTheme -Path (Join-Path $ExportDirectory ($preset + '.json'))
}
}
$targets = @(
[pscustomobject]@{ Target = 'api-east'; Status = 'Pass'; Detail = 'Ready for rollout' }
[pscustomobject]@{ Target = 'api-west'; Status = 'Fail'; Detail = 'Health probe timed out' }
[pscustomobject]@{ Target = 'worker-01'; Status = 'Warn'; Detail = 'Restart scheduled' }
)
$themeReport = New-ConsoleRows -Gap 1 -Content {
New-ConsoleText -Markup '[accent]Build queue[/] [muted]sample data[/]'
New-ConsolePanel -Title 'Checks' -Content {
New-ConsoleStatusList -Content {
[pscustomobject]@{ Label = 'Restore packages'; Status = 'Pass'; Detail = 'complete' }
[pscustomobject]@{ Label = 'Run smoke checks'; Status = 'Warn'; Detail = '1 retry' }
[pscustomobject]@{ Label = 'Deploy api-west'; Status = 'Fail'; Detail = 'blocked' }
[pscustomobject]@{ Label = 'Publish report'; Status = 'Pending'; Detail = 'queued' }
}
}
# Detail takes the spare width, as the Flexible column does in the C# report.
$detail = @{ Name = 'Detail'; Flexible = $true }
$targets |
New-ConsoleTable -Property Target, Status,
$detail -StatusProperty Status -Title 'Targets' -Expand
New-ConsolePanel -Title 'Recent log' -Content {
New-ConsoleLogRegion -Height 3 -Content {
[pscustomobject]@{ Message = 'Loaded deployment plan'; Level = 'Info'; AtSeconds = 1 }
[pscustomobject]@{ Message = 'Smoke check needed one retry'; Level = 'Warning'
AtSeconds = 3 }
[pscustomobject]@{ Message = 'api-west health probe timed out'; Level = 'Error'
AtSeconds = 5 }
}
}
}
Set-ConsoleTheme -Theme $BaseTheme
New-ConsoleRule -Title ('Before: built-in ' + $BaseTheme) | Show-Console -Width $Width
$themeReport | Show-Console -Width $Width
Set-ConsoleTheme -Path $Path
New-ConsoleRule -Title ('After: team ' + $BaseTheme.ToLowerInvariant()) | Show-Console -Width $Width
$themeReport | Show-Console -Width $WidthFull program
<#
.SYNOPSIS
Compare a built-in theme with a team file using the same report.
.DESCRIPTION
Draws illustrative status, table and log widgets twice, then leaves the team
theme active. Download the two team JSON files beside this script. An optional
export folder receives starting JSON files for all five built-in presets.
.PARAMETER BaseTheme
Dark or Light, matching the background of your terminal.
.PARAMETER Path
A JSON or PSD1 theme to apply. Defaults to team-dark.json or team-light.json
beside this script, according to BaseTheme.
.PARAMETER Width
The report width in terminal columns. Use 120 or 60 to compare layouts.
.PARAMETER ExportDirectory
Optional folder to create for Dark, Light, HighContrast, ColorBlindSafeDark and
ColorBlindSafeLight JSON exports. Existing files with those preset names are replaced.
.EXAMPLE
./theme-files.ps1 -BaseTheme Dark -Width 120
.EXAMPLE
./theme-files.ps1 -BaseTheme Light -Width 60 -ExportDirectory ./presets
.OUTPUTS
Draws the report to the host; returns no pipeline objects.
#>
[CmdletBinding()]
param(
[ValidateSet('Dark', 'Light')]
[string] $BaseTheme = 'Dark',
[string] $Path,
[ValidateRange(40, 240)]
[int] $Width = 120,
[string] $ExportDirectory
)
Import-Module ConsoleMonster -ErrorAction Stop
if (-not $Path) {
$Path = Join-Path $PSScriptRoot ('team-' + $BaseTheme.ToLowerInvariant() + '.json')
}
if ($ExportDirectory) {
$null = New-Item -ItemType Directory -Path $ExportDirectory -Force
$presets = 'Dark', 'Light', 'HighContrast', 'ColorBlindSafeDark', 'ColorBlindSafeLight'
foreach ($preset in $presets) {
Set-ConsoleTheme -Theme $preset
Export-ConsoleTheme -Path (Join-Path $ExportDirectory ($preset + '.json'))
}
}
$targets = @(
[pscustomobject]@{ Target = 'api-east'; Status = 'Pass'; Detail = 'Ready for rollout' }
[pscustomobject]@{ Target = 'api-west'; Status = 'Fail'; Detail = 'Health probe timed out' }
[pscustomobject]@{ Target = 'worker-01'; Status = 'Warn'; Detail = 'Restart scheduled' }
)
$themeReport = New-ConsoleRows -Gap 1 -Content {
New-ConsoleText -Markup '[accent]Build queue[/] [muted]sample data[/]'
New-ConsolePanel -Title 'Checks' -Content {
New-ConsoleStatusList -Content {
[pscustomobject]@{ Label = 'Restore packages'; Status = 'Pass'; Detail = 'complete' }
[pscustomobject]@{ Label = 'Run smoke checks'; Status = 'Warn'; Detail = '1 retry' }
[pscustomobject]@{ Label = 'Deploy api-west'; Status = 'Fail'; Detail = 'blocked' }
[pscustomobject]@{ Label = 'Publish report'; Status = 'Pending'; Detail = 'queued' }
}
}
# Detail takes the spare width, as the Flexible column does in the C# report.
$detail = @{ Name = 'Detail'; Flexible = $true }
$targets |
New-ConsoleTable -Property Target, Status,
$detail -StatusProperty Status -Title 'Targets' -Expand
New-ConsolePanel -Title 'Recent log' -Content {
New-ConsoleLogRegion -Height 3 -Content {
[pscustomobject]@{ Message = 'Loaded deployment plan'; Level = 'Info'; AtSeconds = 1 }
[pscustomobject]@{ Message = 'Smoke check needed one retry'; Level = 'Warning'
AtSeconds = 3 }
[pscustomobject]@{ Message = 'api-west health probe timed out'; Level = 'Error'
AtSeconds = 5 }
}
}
}
Set-ConsoleTheme -Theme $BaseTheme
New-ConsoleRule -Title ('Before: built-in ' + $BaseTheme) | Show-Console -Width $Width
$themeReport | Show-Console -Width $Width
Set-ConsoleTheme -Path $Path
New-ConsoleRule -Title ('After: team ' + $BaseTheme.ToLowerInvariant()) | Show-Console -Width $Width
$themeReport | Show-Console -Width $WidthRun: pwsh ./theme-files.ps1 -BaseTheme Dark -Width 120
dotnet new console -n ThemeReport
cd ThemeReport
dotnet add package ConsoleMonsterStatusList checks = new StatusList()
.Add("Restore packages", StatusKind.Pass, "complete")
.Add("Run smoke checks", StatusKind.Warn, "1 retry")
.Add("Deploy api-west", StatusKind.Fail, "blocked")
.Add("Publish report", StatusKind.Pending, "queued");
Table targets = new Table
{
Title = "Targets",
Expand = true
};
targets.Column(new TableColumn("Target") { IsKey = true });
targets.Column(new TableColumn("Status") { Presenter = CellPresenters.StatusWord });
targets.Column(new TableColumn("Detail") { Flexible = true });
targets.Values("api-east", "Pass", "Ready for rollout");
targets.Values("api-west", "Fail", "Health probe timed out");
targets.Values("worker-01", "Warn", "Restart scheduled");
LogRegion log = new LogRegion
{
PreferredHeight = 3
};
log.Write("Loaded deployment plan", "info", TimeSpan.FromSeconds(1));
log.Write("Smoke check needed one retry", "warn", TimeSpan.FromSeconds(3));
log.Write("api-west health probe timed out", "err", TimeSpan.FromSeconds(5));
Rows report = new Rows(
TextBlock.FromMarkup("[accent]Build queue[/] [muted]sample data[/]"),
new Panel(checks, "Checks"),
targets,
new Panel(log, "Recent log"))
{
Gap = 1
};
// Without a file argument, use the terminal's current theme.
if (args.Length == 0)
{
Terminal.Write(report);
}
else
{
using (Terminal.Use(new ReportTarget(Terminal.Target, ThemeFile.Load(args[0]).ToTheme())))
{
Terminal.Write(report);
}
}
// Preserve the current destination and profile while applying this report's palette.
sealed class ReportTarget(ITerminalTarget destination, ITheme theme) : ITerminalTarget
{
public string Name => destination.Name;
public TerminalProfile Profile => destination.Profile;
public ITheme? Theme => theme;
public ITerminalWriter? Writer => destination.Writer;
public IInputSource? Input => destination.Input;
}Full program
using ConsoleMonster;
using ConsoleMonster.Layout;
using ConsoleMonster.Output;
using ConsoleMonster.Capabilities;
using ConsoleMonster.Input;
using ConsoleMonster.Presenters;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;
StatusList checks = new StatusList()
.Add("Restore packages", StatusKind.Pass, "complete")
.Add("Run smoke checks", StatusKind.Warn, "1 retry")
.Add("Deploy api-west", StatusKind.Fail, "blocked")
.Add("Publish report", StatusKind.Pending, "queued");
Table targets = new Table
{
Title = "Targets",
Expand = true
};
targets.Column(new TableColumn("Target") { IsKey = true });
targets.Column(new TableColumn("Status") { Presenter = CellPresenters.StatusWord });
targets.Column(new TableColumn("Detail") { Flexible = true });
targets.Values("api-east", "Pass", "Ready for rollout");
targets.Values("api-west", "Fail", "Health probe timed out");
targets.Values("worker-01", "Warn", "Restart scheduled");
LogRegion log = new LogRegion
{
PreferredHeight = 3
};
log.Write("Loaded deployment plan", "info", TimeSpan.FromSeconds(1));
log.Write("Smoke check needed one retry", "warn", TimeSpan.FromSeconds(3));
log.Write("api-west health probe timed out", "err", TimeSpan.FromSeconds(5));
Rows report = new Rows(
TextBlock.FromMarkup("[accent]Build queue[/] [muted]sample data[/]"),
new Panel(checks, "Checks"),
targets,
new Panel(log, "Recent log"))
{
Gap = 1
};
// Without a file argument, use the terminal's current theme.
if (args.Length == 0)
{
Terminal.Write(report);
}
else
{
using (Terminal.Use(new ReportTarget(Terminal.Target, ThemeFile.Load(args[0]).ToTheme())))
{
Terminal.Write(report);
}
}
// Preserve the current destination and profile while applying this report's palette.
sealed class ReportTarget(ITerminalTarget destination, ITheme theme) : ITerminalTarget
{
public string Name => destination.Name;
public TerminalProfile Profile => destination.Profile;
public ITheme? Theme => theme;
public ITerminalWriter? Writer => destination.Writer;
public IInputSource? Input => destination.Input;
}Run: dotnet run -- ./team-dark.json
dotnet new console -n ThemeReport
cd ThemeReport
dotnet add package ConsoleMonsterStatusList checks = Ui.StatusList()
.Add("Restore packages", StatusKind.Pass, "complete")
.Add("Run smoke checks", StatusKind.Warn, "1 retry")
.Add("Deploy api-west", StatusKind.Fail, "blocked")
.Add("Publish report", StatusKind.Pending, "queued");
Table targets = Ui.Table()
.Title("Targets")
.Expand()
.Column(new TableColumn("Target").Key())
.Column(new TableColumn("Status").Presenter(CellPresenters.StatusWord))
.Column(new TableColumn("Detail").Flexible());
targets.Values("api-east", "Pass", "Ready for rollout");
targets.Values("api-west", "Fail", "Health probe timed out");
targets.Values("worker-01", "Warn", "Restart scheduled");
LogRegion log = Ui.LogRegion().PreferredHeight(3);
log.Write("Loaded deployment plan", "info", TimeSpan.FromSeconds(1));
log.Write("Smoke check needed one retry", "warn", TimeSpan.FromSeconds(3));
log.Write("api-west health probe timed out", "err", TimeSpan.FromSeconds(5));
Rows report = Ui.Rows().Gap(1).Content(rowsContent =>
{
rowsContent.Markup("[accent]Build queue[/] [muted]sample data[/]");
rowsContent.Panel(p => p.Title("Checks").Content(panelContent =>
{
panelContent.Add(checks);
}));
rowsContent.Add(targets);
rowsContent.Panel(p => p.Title("Recent log").Content(panelContent =>
{
panelContent.Add(log);
}));
});
// Without a file argument, use the terminal's current theme.
if (args.Length == 0)
{
report.Show();
}
else
{
using (Terminal.Use(new ReportTarget(Terminal.Target, ThemeFile.Load(args[0]).ToTheme())))
{
report.Show();
}
}
// Preserve the current destination and profile while applying this report's palette.
sealed class ReportTarget(ITerminalTarget destination, ITheme theme) : ITerminalTarget
{
public string Name => destination.Name;
public TerminalProfile Profile => destination.Profile;
public ITheme? Theme => theme;
public ITerminalWriter? Writer => destination.Writer;
public IInputSource? Input => destination.Input;
}
Full program
using ConsoleMonster;
using ConsoleMonster.Layout;
using ConsoleMonster.Output;
using ConsoleMonster.Capabilities;
using ConsoleMonster.Input;
using ConsoleMonster.Presenters;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;
StatusList checks = Ui.StatusList()
.Add("Restore packages", StatusKind.Pass, "complete")
.Add("Run smoke checks", StatusKind.Warn, "1 retry")
.Add("Deploy api-west", StatusKind.Fail, "blocked")
.Add("Publish report", StatusKind.Pending, "queued");
Table targets = Ui.Table()
.Title("Targets")
.Expand()
.Column(new TableColumn("Target").Key())
.Column(new TableColumn("Status").Presenter(CellPresenters.StatusWord))
.Column(new TableColumn("Detail").Flexible());
targets.Values("api-east", "Pass", "Ready for rollout");
targets.Values("api-west", "Fail", "Health probe timed out");
targets.Values("worker-01", "Warn", "Restart scheduled");
LogRegion log = Ui.LogRegion().PreferredHeight(3);
log.Write("Loaded deployment plan", "info", TimeSpan.FromSeconds(1));
log.Write("Smoke check needed one retry", "warn", TimeSpan.FromSeconds(3));
log.Write("api-west health probe timed out", "err", TimeSpan.FromSeconds(5));
Rows report = Ui.Rows().Gap(1).Content(rowsContent =>
{
rowsContent.Markup("[accent]Build queue[/] [muted]sample data[/]");
rowsContent.Panel(p => p.Title("Checks").Content(panelContent =>
{
panelContent.Add(checks);
}));
rowsContent.Add(targets);
rowsContent.Panel(p => p.Title("Recent log").Content(panelContent =>
{
panelContent.Add(log);
}));
});
// Without a file argument, use the terminal's current theme.
if (args.Length == 0)
{
report.Show();
}
else
{
using (Terminal.Use(new ReportTarget(Terminal.Target, ThemeFile.Load(args[0]).ToTheme())))
{
report.Show();
}
}
// Preserve the current destination and profile while applying this report's palette.
sealed class ReportTarget(ITerminalTarget destination, ITheme theme) : ITerminalTarget
{
public string Name => destination.Name;
public TerminalProfile Profile => destination.Profile;
public ITheme? Theme => theme;
public ITerminalWriter? Writer => destination.Writer;
public IInputSource? Input => destination.Input;
}
Run: dotnet run -- ./team-dark.json
Build queue sample data ╭─ Checks ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ ✓ Restore packages complete │ │ ▲ Run smoke checks 1 retry │ │ ✗ Deploy api-west blocked │ │ ○ Publish report queued │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ Targets ╭───────────┬────────┬─────────────────────────────────────────────────────────────────────────────────────────────────╮ │ Target │ Status │ Detail │ ├───────────┼────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤ │ api-east │ ✓ Pass │ Ready for rollout │ │ api-west │ ✗ Fail │ Health probe timed out │ │ worker-01 │ ▲ Warn │ Restart scheduled │ ╰───────────┴────────┴─────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─ Recent log ─────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 00:01 Loaded deployment plan │ │ 00:03 ▲ WARN Smoke check needed one retry │ │ 00:05 ✗ ERR api-west health probe timed out │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Build queue sample data ╭─ Checks ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ ✓ Restore packages complete │ │ ▲ Run smoke checks 1 retry │ │ ✗ Deploy api-west blocked │ │ ○ Publish report queued │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ Targets ╭───────────┬────────┬─────────────────────────────────────────────────────────────────────────────────────────────────╮ │ Target │ Status │ Detail │ ├───────────┼────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤ │ api-east │ ✓ Pass │ Ready for rollout │ │ api-west │ ✗ Fail │ Health probe timed out │ │ worker-01 │ ▲ Warn │ Restart scheduled │ ╰───────────┴────────┴─────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─ Recent log ─────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 00:01 Loaded deployment plan │ │ 00:03 ▲ WARN Smoke check needed one retry │ │ 00:05 ✗ ERR api-west health probe timed out │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Build queue sample data ╭─ Checks ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ ✓ Restore packages complete │ │ ▲ Run smoke checks 1 retry │ │ ✗ Deploy api-west blocked │ │ ○ Publish report queued │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ Targets ╭───────────┬────────┬─────────────────────────────────────────────────────────────────────────────────────────────────╮ │ Target │ Status │ Detail │ ├───────────┼────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤ │ api-east │ ✓ Pass │ Ready for rollout │ │ api-west │ ✗ Fail │ Health probe timed out │ │ worker-01 │ ▲ Warn │ Restart scheduled │ ╰───────────┴────────┴─────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─ Recent log ─────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 00:01 Loaded deployment plan │ │ 00:03 ▲ WARN Smoke check needed one retry │ │ 00:05 ✗ ERR api-west health probe timed out │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Build queue sample data ╭─ Checks ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ ✓ Restore packages complete │ │ ▲ Run smoke checks 1 retry │ │ ✗ Deploy api-west blocked │ │ ○ Publish report queued │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ Targets ╭───────────┬────────┬─────────────────────────────────────────────────────────────────────────────────────────────────╮ │ Target │ Status │ Detail │ ├───────────┼────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤ │ api-east │ ✓ Pass │ Ready for rollout │ │ api-west │ ✗ Fail │ Health probe timed out │ │ worker-01 │ ▲ Warn │ Restart scheduled │ ╰───────────┴────────┴─────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─ Recent log ─────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 00:01 Loaded deployment plan │ │ 00:03 ▲ WARN Smoke check needed one retry │ │ 00:05 ✗ ERR api-west health probe timed out │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
The same report at 120 columns, before and after loading the team file. Switch the site theme to see the matching light palette.
On a light terminal use -BaseTheme Light and team-light.json. The script leaves the team theme active; Set-ConsoleTheme -Theme Dark or -Theme Light restores a built-in, and -ExportDirectory ./presets writes starting files for all five presets. Without an argument the C# program uses the current terminal theme; with a file it scopes the loaded palette to the report's output target with Terminal.Use and restores the target when the report finishes.
Build queue sample data ╭─ Checks ─────────────────────────────────────────────────╮ │ ✓ Restore packages complete │ │ ▲ Run smoke checks 1 retry │ │ ✗ Deploy api-west blocked │ │ ○ Publish report queued │ ╰──────────────────────────────────────────────────────────╯ Targets ╭───────────┬────────┬─────────────────────────────────────╮ │ Target │ Status │ Detail │ ├───────────┼────────┼─────────────────────────────────────┤ │ api-east │ ✓ Pass │ Ready for rollout │ │ api-west │ ✗ Fail │ Health probe timed out │ │ worker-01 │ ▲ Warn │ Restart scheduled │ ╰───────────┴────────┴─────────────────────────────────────╯ ╭─ Recent log ─────────────────────────────────────────────╮ │ 00:01 Loaded deployment plan │ │ 00:03 ▲ WARN Smoke check needed one retry │ │ 00:05 ✗ ERR api-west health probe timed out │ ╰──────────────────────────────────────────────────────────╯
Build queue sample data ╭─ Checks ─────────────────────────────────────────────────╮ │ ✓ Restore packages complete │ │ ▲ Run smoke checks 1 retry │ │ ✗ Deploy api-west blocked │ │ ○ Publish report queued │ ╰──────────────────────────────────────────────────────────╯ Targets ╭───────────┬────────┬─────────────────────────────────────╮ │ Target │ Status │ Detail │ ├───────────┼────────┼─────────────────────────────────────┤ │ api-east │ ✓ Pass │ Ready for rollout │ │ api-west │ ✗ Fail │ Health probe timed out │ │ worker-01 │ ▲ Warn │ Restart scheduled │ ╰───────────┴────────┴─────────────────────────────────────╯ ╭─ Recent log ─────────────────────────────────────────────╮ │ 00:01 Loaded deployment plan │ │ 00:03 ▲ WARN Smoke check needed one retry │ │ 00:05 ✗ ERR api-west health probe timed out │ ╰──────────────────────────────────────────────────────────╯
Build queue sample data ╭─ Checks ─────────────────────────────────────────────────╮ │ ✓ Restore packages complete │ │ ▲ Run smoke checks 1 retry │ │ ✗ Deploy api-west blocked │ │ ○ Publish report queued │ ╰──────────────────────────────────────────────────────────╯ Targets ╭───────────┬────────┬─────────────────────────────────────╮ │ Target │ Status │ Detail │ ├───────────┼────────┼─────────────────────────────────────┤ │ api-east │ ✓ Pass │ Ready for rollout │ │ api-west │ ✗ Fail │ Health probe timed out │ │ worker-01 │ ▲ Warn │ Restart scheduled │ ╰───────────┴────────┴─────────────────────────────────────╯ ╭─ Recent log ─────────────────────────────────────────────╮ │ 00:01 Loaded deployment plan │ │ 00:03 ▲ WARN Smoke check needed one retry │ │ 00:05 ✗ ERR api-west health probe timed out │ ╰──────────────────────────────────────────────────────────╯
Build queue sample data ╭─ Checks ─────────────────────────────────────────────────╮ │ ✓ Restore packages complete │ │ ▲ Run smoke checks 1 retry │ │ ✗ Deploy api-west blocked │ │ ○ Publish report queued │ ╰──────────────────────────────────────────────────────────╯ Targets ╭───────────┬────────┬─────────────────────────────────────╮ │ Target │ Status │ Detail │ ├───────────┼────────┼─────────────────────────────────────┤ │ api-east │ ✓ Pass │ Ready for rollout │ │ api-west │ ✗ Fail │ Health probe timed out │ │ worker-01 │ ▲ Warn │ Restart scheduled │ ╰───────────┴────────┴─────────────────────────────────────╯ ╭─ Recent log ─────────────────────────────────────────────╮ │ 00:01 Loaded deployment plan │ │ 00:03 ▲ WARN Smoke check needed one retry │ │ 00:05 ✗ ERR api-west health probe timed out │ ╰──────────────────────────────────────────────────────────╯
In C#
Add the ConsoleMonster NuGet package to a console project, then use the same file. The core reads JSON; PSD1 belongs to the PowerShell adapter.
using ConsoleMonster;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;
Theme team = ThemeFile.Load("team-dark.json").ToTheme();
Terminal.Theme = team;
Terminal.Write(TextBlock.FromMarkup("[pass]Deployment ready[/]"));
ThemeFile.FromTheme(team).Save("team-snapshot.json");
ThemeFile.Parse accepts JSON text and ThemeFile.Import accepts a data dictionary. ToJson returns complete JSON. Loading and saving do not select a theme; assigning Terminal.Theme does. The same palette can instead be supplied to LiveSessionOptions.Theme for one session.
Check a theme
Test-ConsoleTheme checks the active theme without changing it. Use -Theme for a preset or -Path for a JSON or PSD1 team theme:
Test-ConsoleTheme -Theme ColorBlindSafeLight -Background White
Test-ConsoleTheme -Theme Dark -Detailed
Test-ConsoleTheme -Path ./team-theme.json -Strict
(Test-ConsoleTheme -Theme Dark).Results | Where-Object Outcome -EQ Fail
The default view names the theme and gives a calm verdict, lists only problems and unknowns, and ends with the number of other checks that pass. A pair that fails under several vision conditions appears once, with its lowest distance. -Detailed shows every measurement; the Results property always retains all 28 checks, also for Format-List or Show-ConsoleTable.
The checks cover text contrast (at least 4.5:1 against each role's fill or the page), pass/warning/fail separation (CIELAB distance 25 in normal vision and simulated protanopia, deuteranopia and tritanopia), markers without colour, and Critical's distinct fill. The page defaults to #0c0c0c for dark themes and #ffffff for light themes. -Background overrides it; Surface is chrome, not the page.
Dark and Light correctly fail colour-vision checks; both colour-blind presets pass. Palette indexes, terminal-default foregrounds and dim text have unknown RGB (terminals choose their own dimming) and report Unknown, while marker checks still run. Passed requires every check to pass. -Strict makes any Fail terminating, with the report in the error's TargetObject; Unknown alone does not throw. The settings picker shows a short verdict below its preview.
In C#, call ThemeCheck.Run(theme, new ThemeCheckOptions { Background = Color.FromHex("#ffffff") }) and inspect Passed and Results. The checker measures the theme's true-colour styles; it does not infer the live terminal palette or certify a terminal's rendering.
Next
- Colour schemes: Dracula, Nord, Solarized and others, faithful and accessible.
- Capability detection: how the colour depth and background are detected.
- Environment overrides: pin the theme and colour depth for CI and screenshots.