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

Requirement: Create a new Theme in SharePoint Online.

How to create a new color theme in SharePoint Online?

A SharePoint Online theme is a collection of settings that you can use to adjust the appearance of your site. You can use themes to control the colors, fonts, and layout of your site. SharePoint Online Modern sites (Teams, Communications, and Hub sites) provide 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 sites. In addition, you can create a new theme for a more customized experience for your users.

I’ll show you how to use PowerShell to install themes on SharePoint Online. This is an excellent way for admins, or the site owner themselves, to create their custom SharePoint theme without having to work with CSS at all. How to add a custom theme in SharePoint Online? Creating a custom theme in SharePoint is a quick and easy way to give your site a unique look and feel.

Here are the steps to add a custom theme in SharePoint Online:

Step 1: Create a New Color Theme in SharePoint Online

Create a new theme in SharePoint Online using this Microsoft fluent UI theme designer: https://aka.ms/themedesigner. Customize the primary color, text color, and background color in the theme generator tool and export the theme output.

sharepoint online add custom theme powershell

Step 2: Add Custom Theme to SharePoint Online using PowerShell

Once the theme is created using the theme designer, add the theme color to the SharePoint Online tenant using PowerShell. Open SharePoint Online Management Shell or PowerShell ISE as a SharePoint Admin, make sure you change the Admin center URL to your domain and run this script to add a site theme to SharePoint Online using PowerShell:

#Define the color palette
$ThemePalette = @{
"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 - Prompt for credentials
Connect-SPOService -url $AdminCenterURL -credential (Get-Credential)

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

#Add-SPOTheme -name "Custom Cyan" -Palette $themepalette -IsInverted $false -Overwrite

This PowerShell adds a site theme to SharePoint Online. Use the -Overwrite switch, if you want to overwrite an existing theme. If your account is MFA enabled, use this to connect to SharePoint Online:

#Change the "domain" to your domain
Connect-SPOService -Url https://domain-admin.sharepoint.com

If you go to Site settings gear icon >> Change the Look, You’ll find the new color theme listed under “Company Themes”! You can pick the team, and click on the “Apply” button to change the theme for your SharePoint site collection.

sharepoint online create new theme

I’m assuming you have the SharePoint Online PowerShell module installed already. If not, you’ll see an error message “The term ‘Connect-SPOService’ is not recognized as the name of a cmdlet, function, script file, or operable program.”. You can download and install the latest version of SharePoint Online Management Shell: How to Connect to SharePoint Online from SharePoint Online Management Shell?

SharePoint Online Add Custom Theme using PnP PowerShell

While SharePoint offers a variety of pre-built themes, you may find that you want to create a custom theme that better suits your organization’s needs. You can add a new theme to SharePoint Online using the PnP PowerShell cmdlet Add-PnPTenantTheme. 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. How do I change the default theme in SharePoint online? To apply theme to the SharePoint Online site, use: How to Apply a Theme in SharePoint Online using PowerShell?

Conclusion

In summary, theming allows you to fully customize your SharePoint Online site’s look and feel per your branding needs. You can now easily upload custom themes using PowerShell without dealing with any complex XML markup or Solutions framework. Using Microsoft Theme Designer, we learned how themes are composed of different background images and color palettes. Finally, the steps to connect to SharePoint Online, check existing themes, and add the new custom theme using PowerShell were explained. There are some more PowerShell cmdlets that make the theming process simple:

Using the techniques outlined in this article, you can now build visually impressive SharePoint sites with your own custom themes tailored to your brand style guides.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

One thought on “SharePoint Online: How to Add New Custom Theme using PowerShell?

  • Thank you for putting together a very simple, straight forward post! Will this work for SharePoint Server 2019? I want to add a custom modern them to my SharePoint 2019 intranet.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *