Skip to content

Custom Themes ​

PoshUI provides two approaches for custom theming:

  1. Set-UITheme with hashtables (v1.3.0) - Define color palettes for light and dark modes using simple PowerShell hashtables. This is the recommended approach for most users.
  2. XAML theme files - Full control over WPF resources for advanced customization.

Quick Start: Dual-Mode Hashtable Themes (v1.3.0) ​

The simplest way to customize PoshUI's appearance is with Set-UITheme. Define independent color palettes for light and dark modes:

powershell
# Import your module
Import-Module PoshUI.Dashboard

# Initialize
New-PoshUIDashboard -Title 'My Dashboard'

# Define custom themes for both modes
Set-UITheme -Light @{
    Background        = '#FFF0F5'
    AccentColor       = '#E91E63'
    SidebarBackground = '#880E4F'
    SidebarText       = '#FFFFFF'
    SidebarHighlight  = '#F48FB1'
    ButtonBackground  = '#E91E63'
    ButtonForeground  = '#FFFFFF'
    CardBackground    = '#FFFFFF'
} -Dark @{
    Background        = '#1A1A2E'
    AccentColor       = '#00BFA5'
    SidebarBackground = '#0A1A18'
    SidebarText       = '#E0F2F1'
    SidebarHighlight  = '#B2DFDB'
    ButtonBackground  = '#00BFA5'
    ButtonForeground  = '#000000'
    CardBackground    = '#16213E'
}

# Add steps, cards, etc.
Add-UIStep -Name 'Overview' -Title 'Dashboard'
# ...
Show-PoshUIDashboard

How It Works ​

  • The engine detects the active theme (light or dark) and applies the matching palette
  • Users can toggle between themes at runtime using the sun/moon button in the title bar
  • Custom colors persist across toggles
  • Only specify the slots you want to change; unspecified slots use built-in defaults

Available Color Slots (24 total) ​

SlotDescriptionLight DefaultDark Default
AccentColorPrimary accent color#0078D4#0078D4
AccentDarkAccent hover state (auto-derived if omitted)#005A9E#005A9E
AccentDarkerAccent pressed state (auto-derived if omitted)#004578#004578
AccentLightLight accent variant (auto-derived if omitted)#4A9EE0#4A9EE0
BackgroundOutermost window background#E8ECF0#1E1E2E
ContentBackgroundMain content area#F0F3F6#252535
CardBackgroundCard surfaces#FFFFFF#2D2D3D
SidebarBackgroundSidebar panel#1A202C#16161E
SidebarTextSidebar text#FFFFFF#FFFFFF
SidebarHighlightActive sidebar highlight#4A9EE0#4A9EE0
TextPrimaryPrimary text#1A202C#E8ECF0
TextSecondarySecondary text#4A5568#A0AEC0
ButtonBackgroundButton fill#0078D4#0078D4
ButtonForegroundButton text#FFFFFF#FFFFFF
InputBackgroundInput field background#FFFFFF#2D2D3D
InputBorderInput field border#0078D4#0078D4
BorderColorGeneral borders#CBD5E0#3D3D4D
TitleBarBackgroundTitle bar#1A202C#16161E
TitleBarTextTitle bar text#FFFFFF#FFFFFF
SuccessColorSuccess indicators#107C10#4CAF50
WarningColorWarning indicators#FFB900#FF9800
ErrorColorError indicators#E81123#F44336
FontFamilyGlobal font family nameSegoe UISegoe UI
CornerRadiusControl corner radius in pixels88

Advanced: XAML Theme Resources ​

For full control over WPF resources, you can reference the internal resource keys that PoshUI uses. This is for advanced users who understand WPF ResourceDictionary concepts.

WARNING

The recommended approach for most users is the Set-UITheme hashtable method described above. XAML resource keys are documented here for reference only.

Using the Template ​

The easiest way to start is with the included template:

powershell
# Copy the template to your project
Copy-Item "$PSScriptRoot\..\..\Templates\CustomTheme-Template.xaml" "C:\MyProject\CompanyTheme.xaml"

The template contains every customizable resource key with documentation comments explaining what each one controls.

Minimal XAML Example ​

You don't need to override everything. A minimal theme that only changes the accent color:

xml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <!-- Change the accent color to corporate orange -->
    <Color x:Key="PrimaryColor">#FF6B35</Color>
    <Color x:Key="PrimaryDarkColor">#E05A2B</Color>
    <Color x:Key="PrimaryDarkerColor">#C44A20</Color>
    <Color x:Key="PrimaryLightColor">#FF8F5E</Color>

    <!-- Update brushes that reference accent colors -->
    <SolidColorBrush x:Key="PrimaryBrush" Color="{StaticResource PrimaryColor}"/>
    <SolidColorBrush x:Key="ButtonBackgroundBrush" Color="{StaticResource PrimaryColor}"/>
    <SolidColorBrush x:Key="ButtonHoverBrush" Color="{StaticResource PrimaryDarkColor}"/>
    <SolidColorBrush x:Key="TextBoxFocusBorderBrush" Color="{StaticResource PrimaryColor}"/>
</ResourceDictionary>

Resource Key Reference ​

Accent Colors ​

KeyDescriptionDefault
PrimaryColorMain brand/accent color#0078D4
PrimaryDarkColorHover state#005A9E
PrimaryDarkerColorPressed state#004578
PrimaryLightColorLight highlights#4A9EE0

Semantic Colors ​

KeyDescriptionDefault
SuccessColorSuccess indicators#107C10
WarningColorWarning indicators#FFB900
ErrorColorError indicators#E81123
InfoColorInfo indicators#0078D4

Surface & Background Brushes ​

KeyDescriptionDefault
AppBackgroundBrushOutermost window background#E8ECF0
ContentBackgroundBrushMain content area#F0F3F6
CardBackgroundBrushCard surfaces#FFFFFF
SidebarBackgroundBrushSidebar panel#1A202C

Text Brushes ​

KeyDescriptionDefault
HeadingForegroundBrushHeading textGray900
BodyForegroundBrushBody textGray700
SecondaryForegroundBrushSecondary textGray600
DisabledForegroundBrushDisabled textGray500

Button Brushes ​

KeyDescriptionDefault
ButtonBackgroundBrushPrimary button backgroundPrimaryColor
ButtonForegroundBrushPrimary button text#FFFFFF
ButtonHoverBrushButton hover statePrimaryDarkColor
ButtonPressedBrushButton pressed statePrimaryDarkerColor

Input Brushes ​

KeyDescriptionDefault
TextBoxBackgroundBrushInput field background#FFFFFF
TextBoxFocusBorderBrushFocused input borderPrimaryColor
BorderBrushGeneral bordersGray300

For the complete list of all resource keys, see the template file at PoshUI\Templates\CustomTheme-Template.xaml.

Combining with Theme Mode ​

Set-UITheme works alongside Set-UIBranding -Theme. The base theme (Light/Dark/Auto) is set via branding, and color overrides are layered on top:

powershell
# Set base theme
Set-UIBranding -Theme "Dark"

# Layer custom colors on top
Set-UITheme -Dark @{ AccentColor = '#00BFA5'; SidebarBackground = '#0A1A18' }

Built-in theme modes:

powershell
Set-UIBranding -Theme "Dark"   # Built-in dark theme
Set-UIBranding -Theme "Light"  # Built-in light theme
Set-UIBranding -Theme "Auto"   # Follow Windows system setting

Disabling Animations ​

PoshUI includes smooth transition animations for step navigation, sidebar collapse, and dialog open/close. You can disable these for accessibility or performance:

powershell
Set-UIBranding -Theme "Dark" -DisableAnimations

Error Handling ​

If PoshUI cannot load your custom theme file (invalid XAML, missing file, etc.), it:

  1. Logs a warning with the error details
  2. Falls back to the built-in Light theme
  3. Continues running normally

Check the PoshUI log file for theme loading diagnostics.

Tips ​

  • Start small: Override just the accent colors first, then expand
  • Test both modes: Verify your theme looks good on different monitor sizes
  • Use StaticResource: Reference your Color keys in SolidColorBrush definitions for consistency
  • Keep the file: Store your theme file alongside your scripts for easy distribution

Next: Logging