SharePoint Online: How to Add New Custom Theme using PowerShell?

Requirement: Create New Theme in SharePoint Online.

How to create a new color theme in SharePoint Online?

SharePoint Online Modern sites (Teams, Communications, and Hub sites) provides a set of default themes (Blue, Orange, Red, Purple, Green, and Gray), which you can use to quickly change the look and feel or appearance of your SharePoint Online sites. In addition, you can create a new theme for a more customized experience for your users. Here are the steps to add a custom theme in SharePoint Online:

Step 1: Create New Color Theme in SharePoint Online

Create a new theme in SharePoint Online using this theme designer: https://developer.microsoft.com/en-us/fabric#/styles/themegenerator, Customize and Copy the theme output.

Step 2: Add Custom Theme to SharePoint Online using PowerShell

Once the theme is created using the theme designer, add the theme color to SharePoint Online using PowerShell. Open SharePoint Online Management Shell, run this script to add site theme to SharePoint Online using PowerShell:

#Define the color palette
$ThemePallette = @{
"themePrimary" = "#00d492";
"themeLighterAlt" = "#f3fdfa";
"themeLighter" = "#d0f8eb";
"themeLight" = "#a9f2db";
"themeTertiary" = "#5ce5b9";
"themeSecondary" = "#1ad99c";
"themeDarkAlt" = "#00be82";
"themeDark" = "#00a16e";
"themeDarker" = "#007751";
"neutralLighterAlt" = "#f8f8f8";
"neutralLighter" = "#f4f4f4";
"neutralLight" = "#eaeaea";
"neutralQuaternaryAlt" = "#dadada";
"neutralQuaternary" = "#d0d0d0";
"neutralTertiaryAlt" = "#c8c8c8";
"neutralTertiary" = "#ae9e9e";
"neutralSecondary" = "#938181";
"neutralPrimaryAlt" = "#796767";
"neutralPrimary" = "#0f0b0b";
"neutralDark" = "#443636";
"black" = "#2a2020";
"white" = "#ffffff";
}

#Set Admin Center URL
$AdminCenterURL = "https://crescent-admin.sharepoint.com/"

#Connect to SharePoint Online
Connect-SPOService -url $AdminCenterURL -Credential (Get-Credential)

#Add new SharePoint Online theme
Add-SPOTheme -Name "Crescent Green" -Palette $ThemePalette -IsInverted $False

This PowerShell adds a site theme to SharePoint Online. If you go to Settings gear >> Change the Look, You’ll find the new color theme listed under “Company Themes”!

sharepoint online create new theme

SharePoint Online Add Custom Theme using PnP PowerShell

You can add a new theme to SharePoint Online using PnP PowerShell, with Add-PnPTenantTheme cmdlet. Here is how to create a custom theme in SharePoint Online:

#Parameter
$AdminCenterURL = "https://crescent-admin.sharepoint.com"

#Connect to Admin Center
Connect-PnPOnline -Url $AdminCenterURL -Interactive

#Define Theme
$ThemePalette = @{
    "themePrimary" = "#5fc5df";
    "themeLighterAlt" = "#f8fdfe";
    "themeLighter" = "#e3f5fa";
    "themeLight" = "#cbedf5";
    "themeTertiary" = "#9bdbeb";
    "themeSecondary" = "#71cbe2";
    "themeDarkAlt" = "#56b1c8";
    "themeDark" = "#4995a9";
    "themeDarker" = "#356e7c";
    "neutralLighterAlt" = "#f8f8f8";
    "neutralLighter" = "#f4f4f4";
    "neutralLight" = "#eaeaea";
    "neutralQuaternaryAlt" = "#dadada";
    "neutralQuaternary" = "#d0d0d0";
    "neutralTertiaryAlt" = "#c8c8c8";
    "neutralTertiary" = "#d8baba";
    "neutralSecondary" = "#b17f7f";
    "neutralPrimaryAlt" = "#8d5252";
    "neutralPrimary" = "#7e4343";
    "neutralDark" = "#5f3232";
    "black" = "#462525";
    "white" = "#ffffff";
    "primaryBackground" = "#ffffff";
    "primaryText" = "#7e4343";
    "bodyBackground" = "#ffffff";
    "bodyText" = "#7e4343";
    "disabledBackground" = "#f4f4f4";
    "disabledText" = "#c8c8c8";
}

#powershell to add custom theme in sharepoint online 
Add-PnPTenantTheme -Identity "Corporate Theme" -Palette $ThemePalette -IsInverted $False -Overwrite

This creates a custom theme in SharePoint Online.

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply