The possibility of using and creating themes has been around in SharePoint through many versions back and they have worked in different ways for all versions. For a while ago, a new way to create a custom theme was launched for modern pages (modern themes) in SharePoint Online. In this post I show you how to create your own theme using PowerShell on a tenant level to make a theme available to all modern sites in the tenant. Please note that modern themes is not supported in SharePoint server 2019, this instructions will only work for SharePoint Online and for modern sites.

What you can accomplish with a theme is quite limited, but at least you can put your own background color onto the page and change the primary color for certain types of elements to get a simple color match based on a graphic profile.

theme

Let’s try it out!

Before following the steps below, make sure you have the latest version of SharePoint Online Management shell installed and that you have access to a tenant admin account in order to run the PowerShell that’s needed for the theme deployment.

    • Define the theme colors
      The easiest way would to use Microsoft UI Fabric Theme Designer online. You’ll find two different versions you can use through the links below. You simply choose between three main colors; a primary color, the text color and a background color. Once you have done that you can export or copy the result in PowerShell format.

    • Apply the theme in SharePoint
      • Open Windows PowerShell ISE (run it as an administrator) or similar PowerShell tool of your choice.
      • Paste what’s follows in the the PS editor and run it, section by section, first connect then set the variable and last you add the theme in SharePoint:

# Connect to the tenant as admin

$username = xxxxx@xxxxx.onmicrosoft.com">xxxxx@xxxxx.onmicrosoft.com
$password = "xxxxx"
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force)
Connect-SPOService -Url https://xxxxx-admin.sharepoint.com/ -Credential $cred

#Set the theme as a variable

$MyCustomTheme= @{
"themePrimary" = "#bc4ab8";
"themeLighterAlt" = "#fcf6fc";
"themeLighter" = "#f4ddf4";
"themeLight" = "#ebc0ea";
"themeTertiary" = "#d788d5";
"themeSecondary" = "#c55bc1";
"themeDarkAlt" = "#aa42a6";
"themeDark" = "#8f388c";
"themeDarker" = "#6a2968";
"neutralLighterAlt" = "#e7e7e7";
"neutralLighter" = "#e3e3e3";
"neutralLight" = "#dadada";
"neutralQuaternaryAlt" = "#cbcbcb";
"neutralQuaternary" = "#c2c2c2";
"neutralTertiaryAlt" = "#bababa";
"neutralTertiary" = "#c6c6c6";
"neutralSecondary" = "#8c8c8c";
"neutralPrimaryAlt" = "#575757";
"neutralPrimary" = "#404040";
"neutralDark" = "#303030";
"black" = "#242424";
"white" = "#eeeeee";
"primaryBackground" = "#eeeeee";
"primaryText" = "#404040";
"bodyBackground" = "#eeeeee";
"bodyText" = "#404040";
"disabledBackground" = "#e3e3e3";
"disabledText" = "#bababa";
}

# Add the theme

Add-SPOTheme -Identity "MyCustomTheme" -Palette $MyCustomTheme -IsInverted $false

# Some more useful cmdlets

# Remove a theme
Remove-SPOTheme -Identity "MyCustomTheme"
# Hide the default themes
Set-SPOHideDefaultThemes $true
# UnHide the default themes
Set-SPOHideDefaultThemes $false

In this post I showed you how to apply a modern theme for modern sites in SharePoint Online. In the next post I’ll show you how to define and apply a theme in a site design (modern site template), and later I’ll write a post about the possibilities for more advanced branding techniques in SharePoint, what to do when a theme is not enough. If you have any question regarding this, please drop a comment and I’ll get back to you.

Stay in tune SharePoint friends!