Skip to content

Platform Theming ​

PoshUI features a native Windows 11-style theming system that supports both Light and Dark modes. The theme can be configured to follow the system settings or forced to a specific style.

Light ThemeDark Theme
Dashboard LightDashboard Dark

Theme Modes ​

ModeDescription
Auto(Default) Automatically detects the Windows system theme from the registry.
LightForces a high-contrast light theme with white backgrounds and grey borders.
DarkForces a modern dark theme with deep charcoal backgrounds and vibrant accents.

Setting the Theme ​

You can set the theme during initialization or later using branding cmdlets.

During Initialization ​

powershell
New-PoshUIWizard -Title "Setup" -Theme "Dark"

Using Set-UIBranding ​

powershell
Set-UIBranding -Theme "Light"

How It Works ​

The C# engine (PoshUI.exe) uses WPF ResourceDictionaries to manage themes. When the theme is set to Auto, the engine reads the following registry key to determine the user's preference:

  • Key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize
  • Value: AppsUseLightTheme (0 = Dark, 1 = Light)

UI Elements Affected ​

The theming system applies consistently to all visual elements:

  • Window Chrome: Title bar and borders.
  • Sidebar: Background, selection highlights, and text.
  • Form Controls: Backgrounds, borders, focus states, and placeholder text.
  • Dashboard Cards: Backgrounds, shadows, and metric values.
  • Execution Console: Background and text colors (optimized for readability).

Theme Toggle (v1.3.0) ​

A sun/moon toggle button in the title bar allows users to switch between light and dark themes at runtime. The toggle is always available and works with both built-in and custom themes.

Dual-Mode Custom Themes (v1.3.0) ​

Use Set-UITheme to define independent color palettes for light and dark modes. The engine applies the correct palette automatically based on the active theme, and custom colors persist when the user toggles between modes.

powershell
# Define different palettes for each mode
Set-UITheme -Light @{
    Background        = '#FFF0F5'
    AccentColor       = '#E91E63'
    SidebarBackground = '#880E4F'
    SidebarText       = '#FFFFFF'
    ButtonBackground  = '#E91E63'
} -Dark @{
    Background        = '#1A1A2E'
    AccentColor       = '#00BFA5'
    SidebarBackground = '#0A1A18'
    SidebarText       = '#E0F2F1'
    ButtonBackground  = '#00BFA5'
}

Available Color Slots ​

SlotDescription
BackgroundOutermost window background
ContentBackgroundMain content area background
CardBackgroundCard surface color
SidebarBackgroundSidebar panel background
SidebarTextSidebar text color
SidebarHighlightActive sidebar item highlight
TextPrimaryPrimary text color
TextSecondarySecondary/muted text
AccentColorPrimary accent (buttons, highlights)
ButtonBackgroundButton fill color
ButtonForegroundButton text color
InputBackgroundText input background
InputBorderText input border
BorderColorGeneral border color
TitleBarBackgroundTitle bar background
TitleBarTextTitle bar text
SuccessColorSuccess state indicators
WarningColorWarning state indicators
ErrorColorError state indicators
HeadingForegroundHeading text color
BodyForegroundBody text color
SecondaryForegroundSecondary text color

Only specify the slots you want to override. Unspecified slots use the built-in theme defaults.

Custom Colors on Controls ​

Some controls also accept custom hex color overrides directly:

powershell
Add-UICard -Step 'Config' -Title 'Success' -BackgroundColor '#0078D4' -ContentColor '#FFFFFF'

TIP

When using custom colors, ensure they maintain high contrast for accessibility in both light and dark environments.

Next: Validation