In my previous post I demonstrated how to add Megamenu navigation and Footer to Modern SharePoint Communication sites. In this post I will show how to create and add custom Site Theme to Modern SharePoint Sites and apply the Theme to all Hub Sites at once.
SharePoint Online Site Themes
SharePoint Online Sites have ability to change site theme from eight ready-made out-of-the-box site themes. You can select the theme by clicking the Gear -icon from Office 365 ribbon and then select Change the look -link from the drop down menu. In Change the look -dialog there is theme -option where you can find Site Themes.
If you have requirement to tune your site colors, you can start to customize out-of-the-box SharePoint Themes by selecting the theme and clicking Customize -link. See picture below.

That way you can change main and accent colors to the site theme.

Create custom Site Theme
Microsoft has created good documentation how to create Custom Site Themes. We need to create custom color palette for theme and apply that to the SharePoint Online tenant.
We can use Microsoft Theme generator for creating custom color palette for our theme. In Theme generator you can select colors and you get PowerShell or JSON code as output.

Add Theme to SharePoint Online Tenant with PowerShell
When you have finished your theme colors in Theme Generator, take and copy the PowerShell Output.
#Powershell
@{
"themePrimary" = "#e20a16";
"themeLighterAlt" = "#fef4f5";
"themeLighter" = "#fbd4d6";
"themeLight" = "#f7b0b3";
"themeTertiary" = "#ee656c";
"themeSecondary" = "#e6242d";
"themeDarkAlt" = "#cc0812";
"themeDark" = "#ac070f";
"themeDarker" = "#7f050b";
"neutralLighterAlt" = "#f8f8f8";
"neutralLighter" = "#f4f4f4";
"neutralLight" = "#eaeaea";
"neutralQuaternaryAlt" = "#dadada";
"neutralQuaternary" = "#d0d0d0";
"neutralTertiaryAlt" = "#c8c8c8";
"neutralTertiary" = "#595959";
"neutralSecondary" = "#373737";
"neutralPrimaryAlt" = "#2f2f2f";
"neutralPrimary" = "#000000";
"neutralDark" = "#151515";
"black" = "#0b0b0b";
"white" = "#ffffff";
}
Apply your code to the PowerShell Script and Run Add-SPOTheme command in SharePoint Online PowerShell. Take my script below or see instructions from Microsoft Add-SPOTheme documentation.
$adminSiteUrl = "https://tenant-admin.sharepoint.com"
$themeName = "C Custom Theme"
$cred = Get-Credential
Connect-SPOService $adminSiteUrl -Credential $cred
$theme = @{
"themePrimary" = "#e20a16";
"themeLighterAlt" = "#fef4f5";
"themeLighter" = "#fbd4d6";
"themeLight" = "#f7b0b3";
"themeTertiary" = "#ee656c";
"themeSecondary" = "#e6242d";
"themeDarkAlt" = "#cc0812";
"themeDark" = "#ac070f";
"themeDarker" = "#7f050b";
"neutralLighterAlt" = "#f8f8f8";
"neutralLighter" = "#f4f4f4";
"neutralLight" = "#eaeaea";
"neutralQuaternaryAlt" = "#dadada";
"neutralQuaternary" = "#d0d0d0";
"neutralTertiaryAlt" = "#c8c8c8";
"neutralTertiary" = "#595959";
"neutralSecondary" = "#373737";
"neutralPrimaryAlt" = "#2f2f2f";
"neutralPrimary" = "#000000";
"neutralDark" = "#151515";
"black" = "#0b0b0b";
"white" = "#ffffff";
}
Add-SPOTheme -Name $themeName -Palette $theme -IsInverted:$false
Change site theme in Hub site collection
After you Powershell command is successfully implemented, you should see your custom theme in Change the Look > Theme settings.

Site theme will be inherited from the Root Hub Site to the associated Hub sites. That’s nice because you don’t need to change the Theme in every associated hub sites.


Conclusions
That was my post about the custom site themes in SharePoint Online.