Usage of DashboardColor vs color as a string seems to be inconsistent, and I haven’t seen a document page that actually defines what the allowed values are.
DashboardColor has a parse method that tries to convert the string into the proper color. When you pass a string to a DashboardColor parameter, that value is passed into this.
public static DashboardColor Parse(string hexOrName)
{
if (hexOrName.StartsWith("#"))
{
hexOrName = hexOrName.TrimStart('#');
if (hexOrName.Length == 3)
{
hexOrName += hexOrName;
}
if (hexOrName.Length != 3 && hexOrName.Length < 6)
{
while (hexOrName.Length < 6)
{
hexOrName = "0" + hexOrName;
}
}
if (hexOrName.Length == 6)
{
hexOrName = "FF" + hexOrName;
}
Int32 iColorInt = Convert.ToInt32(hexOrName.Substring(0), 16);
return new DashboardColor(iColorInt);
}
else if ((hexOrName.ToLower()).Equals("transparent"))
{
var color = Color.FromArgb(0, 0, 0, 0);
return new DashboardColor(color);
}
else if (hexOrName.StartsWith("rgb"))
{
return new DashboardColor(hexOrName);
}
else
{
var color = Color.FromName(hexOrName);
return new DashboardColor(color);
}
}
So that means you can pass it:
# Hex color
New-UDIcon -Icon User -Color '#2596be'
# RGB values
New-UDIcon -Icon User -Color 'rgb(37, 150, 190)'
# Anything Color.FromName knows
New-UDIcon -Icon User -Color 'gray'
It’s a bit of a consistency issue. Some components use the MUI standard colors like primary secondary etc while some use the DashboardColor. It will depend on the component and the parameter is state as such.
The DashboardColor class is kind of a historical thing and from our original implementation of Universal Dashboard.
I’ve got a couple of example posts here in the forums (icon search, color palette). @adam is welcome to use them if/how he wishes! I’m hoping to keep adding examples of things to beef up some of the search results. Not saying I’m doing any of this the right/best way, just a “works for me” way