How to Create a Custom SharePoint Theme

Author by Kianna DeByle

How to Create a Custom SharePoint Theme

Microsoft offers a great tool that allows you to create your own SharePoint themes through Office Fabric UI. It allows you to plug in three colors (primary color, text color, and background color) and will then generate a SharePoint theme that can be pushed to your SharePoint site with a simple PowerShell script.

Let me show you how you can do this. You will need admin access to a SharePoint tenant before getting started.

Step 1:

First thing we will need to do is create the custom theme by using the UI Fabric Theme Designer from Microsoft’s Office Fabric UI site. When you get to the site you should see a screen like this:

As you can see, on the left is where you can enter the hex codes for the colors you would like to use. For example, if I enter red, blue and green, this is the result.

At the top it shows you an example of what your SharePoint theme will do to your site.

Below that it shows any accessibility errors created when you used the colors you chose. It is best practice to make sure you do not have any accessibility errors in the theme you choose.

Below the accessibility checker, you have theme slots. This is where the theme generator will create various shades to be used on the site. This is helpful because you do not have to make your own hierarchy for colors on the site. The theme generator does it all for you.

Go ahead and enter the colors you want to use in your theme and see what you are able to generate. Feel free to play around with it a bit until you get something you like!

Here is what I created:

Step 2: Exporting the theme to PowerShell Script.

Now that we have a theme created, we need to get it added to our SharePoint tenant. To do this, we are going to export the theme to PowerShell.

To do that, click “export theme” in the top right corner of the screen.

Once you click this, a side panel should appear. The panel defaults to code, we need to click “PowerShell” to generate the PowerShell script.

Once you have that open, you should have a script generated. Keep this screen open as we will need it next. Your script should look similar to this.

Now we need to push this script to our site.

Step 3: Connecting to your tenant with PowerShell

Open PowerShell on your computer. We will first have to connect to the SharePoint tenant we want the theme to go on. To do that, enter the command below.

After hitting enter, you should be prompted to enter the URL for your SharePoint admin center. It should look like what you see entered below.

After you have entered the URL you will be prompted to sign in with the credential you use to access the tenant. Go ahead and log in.

Step 4: Pushing the script to SharePoint

Now we can upload our script! The script generated for us by the theme generator, however, is incomplete. Here is the complete script, I have highlighted the parts that will be replaced by the script generated with the theme generator.

 

$themepalette =@{

"themePrimary" = "#00000";

"themeLighterAlt" = "#00000";

"themeLighter" = "#00000";

"themeLight" = "#00000";

"themeTertiary" = "#00000";

"themeSecondary" = "#00000";

"themeDarkAlt" = "#00000";

"themeDark" = "#00000";

"themeDarker" = "#00000";

"neutralLighterAlt" = "#00000";

"neutralLighter" = "#00000";

"neutralLight" = "#00000";

"neutralQuaternaryAlt" = "#00000";

"neutralQuaternary" = "#00000";

"neutralTertiaryAlt" = "#00000";

"neutralTertiary" = "#00000";

"neutralSecondary" = "#00000";

"neutralPrimaryAlt" = "#00000";

"neutralPrimary" = "#00000";

"neutralDark" = "#00000";

"black" = "#00000";

"white" = "#00000";

}

Add-SPOTheme -Identity "MyTheme" -Palette $themepalette -IsInverted $false

 

Go ahead and replace the highlighted script with the script you generated earlier. You can simply highlight and replace by pasting.

Here is what mine looks like:

$themepalette =@{

"themePrimary" = "#444554";

"themeLighterAlt" = "#f6f6f8";

"themeLighter" = "#dddde4";

"themeLight" = "#c0c1cc";

"themeTertiary" = "#878898";

"themeSecondary" = "#575869";

"themeDarkAlt" = "#3d3e4c";

"themeDark" = "#343540";

"themeDarker" = "#26272f";

"neutralLighterAlt" = "#f8f8f8";

"neutralLighter" = "#f4f4f4";

"neutralLight" = "#eaeaea";

"neutralQuaternaryAlt" = "#dadada";

"neutralQuaternary" = "#d0d0d0";

"neutralTertiaryAlt" = "#c8c8c8";

"neutralTertiary" = "#a1b4b4";

"neutralSecondary" = "#869b9b";

"neutralPrimaryAlt" = "#6d8383";

"neutralPrimary" = "#172121";

"neutralDark" = "#3f5252";

"black" = "#2a3a3a";

"white" = "#ffffff";

}Add-SPOTheme -Identity "MyTheme" -Palette $themepalette -IsInverted $false

 

Take note that many times, a line break is removed after the last bracket before the part that says “Add-SPOTheme….” Go ahead and make sure that “Add-SPOTheme…” and everything after it is on its own line after the bracket. Then go ahead and copy the entire script and paste it into your PowerShell terminal.

You can rename your theme by changing the text inside the “” after identity. In this example, I have named the theme “MyTheme”

Should look like this:

Hit enter and your theme should be uploaded. If you get any errors, check that your script is correctly formatted and try again.

Now let’s see our theme.

Step 5: Setting the theme in SharePoint

Go ahead now and open up a site in your tenant and try and set the theme. You can set the theme by clicking the gear icon in the top right corner of your screen here:

And then click "Change the Look"

Select “Theme” and then find the new theme you had created. Click on it to set it then click “Save” and you should see your new theme on your site!