|
| 1 | + |
| 2 | + |
| 3 | +# Apply site theme |
| 4 | + |
| 5 | +## Summary |
| 6 | + |
| 7 | +Apply a theme to a specific SharePoint site without adding a tenant theme that would be available for all sites through the "Change the look" menu. |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | +# [PnP PowerShell](#tab/pnpps) |
| 13 | + |
| 14 | +```powershell |
| 15 | +
|
| 16 | +$siteUrl = "https://contoso.sharepoint.com/sites/DemoSite" |
| 17 | +
|
| 18 | +$themePalette = @{ |
| 19 | + "palette" = @{ |
| 20 | + "themePrimary"= "#1BF242"; |
| 21 | + "themeLighterAlt"= "#0d0b00"; |
| 22 | + "themeLighter"= "#0b35bc"; |
| 23 | + "themeLight"= "#322d00"; |
| 24 | + "themeTertiary"= "#6a5f00"; |
| 25 | + "themeSecondary"= "#1B22F2"; |
| 26 | + "themeDarkAlt"= "#ffe817"; |
| 27 | + "themeDark"= "#ffed4b"; |
| 28 | + "themeDarker"= "#fff171"; |
| 29 | + "neutralLighterAlt"= "#252525"; |
| 30 | + "neutralLighter"= "#282828"; |
| 31 | + "neutralLight"= "#313131"; |
| 32 | + "neutralQuaternaryAlt"= "#3f3f3f"; |
| 33 | + "neutralQuaternary"= "#484848"; |
| 34 | + "neutralTertiaryAlt"= "#4f4f4f"; |
| 35 | + "neutralTertiary"= "#c8c8c8"; |
| 36 | + "neutralSecondaryAlt"= "#d0d0d0"; |
| 37 | + "neutralSecondary"= "#dadada"; |
| 38 | + "neutralPrimary"= "#ffffff"; |
| 39 | + "neutralDark"= "#eaeaea"; |
| 40 | + "black"= "#f8f8f8"; |
| 41 | + "white"= "#1f1f1f"; |
| 42 | + "primaryBackground"= "#1f1f1f"; |
| 43 | + "primaryText"= "#ffffff"; |
| 44 | + "error"= "#ff5f5f" |
| 45 | + } |
| 46 | +} |
| 47 | +
|
| 48 | +Connect-PnPOnline -Url $siteUrl -ClientId "" -Interactive |
| 49 | +
|
| 50 | +$accessToken = Get-PnPAccessToken -ResourceTypeName SharePoint |
| 51 | +$bodyObject = @{ |
| 52 | + name = "Sample theme" |
| 53 | + themeJson = ($themePalette | ConvertTo-Json -Depth 10 -Compress) |
| 54 | +} |
| 55 | +
|
| 56 | +$bodyJson = $bodyObject | ConvertTo-Json -Depth 10 |
| 57 | +
|
| 58 | +$headers = @{ |
| 59 | + "Authorization" = "Bearer $accessToken" |
| 60 | + "Accept" = "application/json;odata.metadata=minimal" |
| 61 | + "Content-type" = "application/json; charset=utf-8" |
| 62 | + "ODATA-VERSION" = "4.0" |
| 63 | +} |
| 64 | +
|
| 65 | +$uri = "$siteUrl/_api/thememanager/Applytheme" |
| 66 | +
|
| 67 | +Invoke-RestMethod -Method POST -Uri $uri -Headers $headers -Body $bodyJson |
| 68 | +
|
| 69 | +Disconnect-PnPOnline |
| 70 | +
|
| 71 | +``` |
| 72 | +[!INCLUDE [More about PnP PowerShell](../../docfx/includes/MORE-PNPPS.md)] |
| 73 | + |
| 74 | + |
| 75 | +*** |
| 76 | + |
| 77 | +## Contributors |
| 78 | + |
| 79 | +| Author(s) | |
| 80 | +|-----------| |
| 81 | +| [Aimery Thomas](https://github.com/a1mery)| |
| 82 | + |
| 83 | +[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)] |
| 84 | +<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/spo-apply-site-theme" aria-hidden="true" /> |
0 commit comments