Universal Dashboard v3 is built on Material UI. Material UI provides a built-in theme system that UD now takes advantage of. You can utilize this theme system by providing a hashtable of options to the New-UDDashboard
's -Theme
parameter.
Here's an example of changing the theme's main color.
You can set the default theme to either Light or Dark using the -DefaultTheme
parameter.
You can change the page background color by setting the background default color. To adjust the header background color, set the primary main color.
To support dark and light palettes, you can define a dark and light sections in your hashtable. They have the same properties as a theme.
To change the font size, set the typography fontSize property.
For a full list of options available for the theme system, you can look at the default theme for Material UI.
UDStyle component for Universal Dashboard
You can apply styles to individual components within Universal Dashboard by using the UDStyle
component. This component will need to be added to your dashboard and is part of the core components included with PowerShell Universal.
To apply a style to a component or a set of components, you call the New-UDStyle
cmdlet, specify a CSS style and then include the components you wish to style within the -Content
script block.
Each Material UI component has a set of built in classes that you can override using New-UDStyle
. To determine the class names that you need to override, you can view the API documentation for the component you are trying to modify on the Material UI site. For example, here is a listing of the Alert component's CSS class names.
When using a success alert, you will have the .MuiAlert-standardSuccess
class applied to your component. You can override this default style like this.
The resulting alert will be red instead of the default green.
Use cascading style sheets with Universal Dashboard.
You can use a cascading style sheet (CSS) by add a .css
file to a published folder and then passing it to the -Stylesheets
parameter for New-UDDashboard
.
For example, the dashboard.ps1
file would look like this.
You could then setup a published folder to provide the assets route. This is what the contents of publishedFolders.ps1
will look like.
Within the C:\assets
folder, you can place any assets you'd like to access on the /assets
route.
You can then create a style sheet to manipulate whatever portion of the dashboard you'd like.
This produces a dashboard with a background image of Austin the dog sleeping in a pile of dirt.
Every Material UI component has a series of global class names that you can use to apply styles throughout your dashboard. To determine the correct class names, you can view the a particular component's API documentation. There is a list of the global class names that apply to that component.
For example, here is the CSS documentation for the Alert component.
Within your CSS file, you can use these class names to override styles throughout your dashboard. If you wanted to set all success alerts to have a red background, you could create a CSS file like this.