Setting button colors in PowerShell Universal Dashboard

Image Description

Daily PowerShell #68

Daily PowerShell PowerShell Universal Universal Dashboard

January 14, 2022

quote Discuss this Article

In this post, we’ll look at how to set button colors in PowerShell Universal Dashboard.

Using the -Color Parameter

The -Color parameter is used to set between the primary and secondary theme colors. When the theme changes, the button colors will automatically change.

New-UDButton -Text 'Primary' -Color primary 
New-UDButton -Text 'Secondary' -Color secondary

Using the -Style Parameter

The -Style parameter allows you to set the button colors using CSS styles. You can set the foreground and background colors by defining them in a hashtable.

New-UDButton -Text 'Styled' -Style @{
    backgroundColor = 'red'
    color = 'white'
}

Using Theme Overrides

You can override the button colors in the theme so it applies to all buttons.

$Theme = @{
   overrides = @{
       MuiButton = @{
           root = @{
               backgroundColor = 'blue !important'
               color = 'white !important'
           }
       }
   }
}
New-UDDashboard -Theme $Theme -Title 'Hello' -Content {
    New-UDButton -Text 'Themed'
}