How to create custom theme for SharePoint Modern site using PnP PowerShell

By Dipak Shaw

May 19, 2021


Microsoft, Microsoft SharePoint, Modern Site, Office365, SharePoint Online, SharePointPnPPowerShell

In this blog we will discuss how we can change the theme for a SharePoint site. Although there are some out of the box themes are available but sometimes, we need to match the colors to meet our client requirements.

To access the out of the box themes. Go to gear icon in the top right corner then select Change the look then Theme option and you will see the OOTB themes.

To create your own custom theme, follow these steps below:

Step 1: Create a custom theme using Fluent UI Theme Designer

Go to this URL  and select the color code in the left pane.

My color palette used for demo

Choose the colours according to your requirement. Upon selecting the colours, you will see the preview in the sample page.

For example, my selected color is the above one. This Theme designer is showing me my color preview on its sample page.

Sample preview of the selected colors

Now click the Export button on the top right corner in this designer page.

Now select the PowerShell tab and copy all the code and paste it in a notepad.

Our color code is ready now we will move to Step 2.

Step 2: Run the PowerShell command to install the theme.

Download SharePoint Online Management Shell from this link. Follow the prompts to install it on your computer.

Open the SharePoint Online Management Shell that you just installed.

Open the SharePoint Online Management Shell from windows program

Paste the following command in the PowerShell

Connect-SPOService -Url https://domain-admin.sharepoint.com

Where the “domain” will be replaced with your SharePoint domain. For e.g., my domain is powersolution so I will use
Connect-SPOService -Url https://powersolution-admin.sharepoint.com

*Note: you must have SharePoint admin access to proceed further.

Now you will prompt to enter your credentials.

Now type the code:

$themepalette = 

And then paste the color code that you copied in the Step 1 and press Enter. Altogether the code will look like this –

Next, paste the following code in the PowerShell –

Add-SPOTheme -Identity “Name of your theme” -Palette $themepalette -IsInverted $false

Give your theme a name. For e.g., if I want to name it “Power Solution default” then my complete code will be –
 Add-SPOTheme -Identity “Power Solution default” -Palette $themepalette -IsInverted $false

Press Enter. Congratulations, you successfully installed a custom theme on your SharePoint site. Now the last step is to apply the theme in our site.

Step 3: Applying theme in SharePoint site

Open your SharePoint site, click on the gear icon then select Change the look then Theme option and you will see your installed theme under Company Themes.

Simply select the theme and click Save button and voilà its applied on your site.

For more commands regarding theming refer this post

The difference between OOTB and custom theme is below.

My site before applying custom
My site after applying custom theme

Well, That’s the end of this post. Let me know if you have any query or suggestion in comment below. I’ll see you next time. 😊🙏

Leave a Reply

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

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}