Introduction
Customizing the look and feel of your SharePoint Online site enhances user experience and helps reflect your organization’s branding. By using PowerShell and the SharePoint Online Management Shell, you can efficiently create and apply custom themes across your sites. In this guide, we’ll walk you through the process step-by-step.
Prerequisites
Before you begin, ensure the following:
-
Install SharePoint Online Management Shell:
If you haven’t installed it yet, download it from here.
-
Connect to SharePoint Online via PowerShell:
Open PowerShell and run the following command to connect to your SharePoint tenant:
Code
Connect-SPOService -Url https://<your-tenant>-admin.sharepoint.com -Credential $userCredential
Replace <your-tenant> with your SharePoint tenant name. You will be prompted to enter your admin credentials.
Step 1. Generate a Custom Theme Palette
To create a custom theme, you need to define a theme palette. You can either manually specify the colors or use the Fluent UI Theme Designer to generate one.
Here’s a sample theme palette:
$ThemePalette = @{
"themePrimary" = "#8e7fe5"
"themeLighterAlt" = "#faf9fe"
"themeLighter" = "#ece9fb"
"themeLight" = "#dbd6f7"
"themeTertiary" = "#b9aff0"
"themeSecondary" = "#9a8ce9"
"themeDarkAlt" = "#8072cf"
"themeDark" = "#6c60ae"
"themeDarker" = "#4f4781"
"neutralLighterAlt" = "#d0d8ba"
"neutralLighter" = "#ccd4b7"
"neutralLight" = "#c4ccaf"
"neutralQuaternaryAlt"= "#b7bea3"
"neutralQuaternary" = "#aeb59c"
"neutralTertiaryAlt" = "#a7ae96"
"neutralTertiary" = "#f9d7d7"
"neutralSecondary" = "#f3b0b0"
"neutralPrimaryAlt" = "#ed8d8d"
"neutralPrimary" = "#eb8080"
"neutralDark" = "#b26060"
"black" = "#834747"
"white" = "#d6dec0"
"primaryBackground" = "#d6dec0"
"primaryText" = "#eb8080"
"bodyBackground" = "#d6dec0"
"bodyText" = "#eb8080"
"disabledBackground" = "#ccd4b7"
"disabledText" = "#a7ae96"
}
Step 2. Add the Custom Theme to SharePoint Online
Now that you have your theme palette, you can add the theme to SharePoint Online by using the Add-SPOTheme cmdlet.
Code
Add-SPOTheme -Identity "Test Custom Theme" `
-Palette $ThemePalette `
-IsInverted $false `
-Overwrite
- Identity: The name of your custom theme, e.g., "Test Custom Theme."
- Palette: The color palette we defined in the previous step.
- IsInverted: Set to $false for a standard theme or $true for a high-contrast inverted theme.
- Overwrite: This ensures that the theme will overwrite an existing one if it has the same name.
After running this command, your theme will become available across all SharePoint sites.
Output
Step 3. Apply the Custom Theme to a Specific SharePoint Site
To apply the custom theme to a particular site collection, use the Set-SPOTheme cmdlet:
Code
Set-SPOTheme -Identity "Test Custom Theme" -WebUrl https://<your-site>.sharepoint.com/sites/YourSiteCollection
Replace <your-site> with the URL of the SharePoint site where you want to apply the theme.
Additional Notes
- You can create and apply multiple themes for different environments, such as development and production.
- To test the theme, apply it to a SharePoint site and verify that all elements, like buttons, headers, and backgrounds, reflect the custom colors.
- The Fluent UI Theme Designer can help you visually create and test color combinations before deploying them to your SharePoint environment.
Conclusion
Custom themes provide a consistent and branded user experience across your SharePoint Online sites. With PowerShell, you can quickly deploy these themes across multiple site collections, saving time and ensuring uniformity. By leveraging the Fluent UI Theme Designer and the Add-SPOTheme cmdlet, you can align your SharePoint environment with your organization’s branding easily and efficiently.