SharePoint 网站主题SharePoint site theming

SharePoint 网站所有者可以使用新功能向网站应用自定义样式和颜色,从而更轻松地跨网站集定义和管理主题。SharePoint site owners have new options for applying custom styles and colors to sites that make it easier to define and manage themes across site collections.

这些新功能包括:These new features include:

  • 可以定义自定义主题,以供网站所有者使用。The ability to define custom themes and make them available to site owners. 主题是在 JSON 架构中进行定义,其中存储每个主题的颜色设置和相关元数据。Themes are defined in a JSON schema that stores color settings and related metadata for each theme.
  • 可用于定义新自定义主题的联机主题生成器工具An online Theme Generator tool that you can use to define new custom themes.
  • 可以使用一组简化的默认主题,其中目前包含六个浅色主题和两个深色主题。A simplified set of default themes, with six light themes and two dark themes presently available.
  • 更新后的调色板,其中包含 12 个浅色主题和 6 个深色主题以及 16 个补充主题。An updated color palette, with 12 light colors and 6 dark colors, as well as 16 supplementary themes.
  • 可以控制哪些主题可应用到网站页面。Control over which themes are available for use on pages within your sites. 例如,可以根据组织的品牌或标识定义自定义主题,并将这些主题设为网站中唯一可用的主题。For example, you can define custom themes based on your organization's branding or identity, and make those the only available themes within your sites.

管理员可通过 PowerShell cmdlet 使用这些功能,开发者可通过 SharePoint 客户端对象模型 (CSOM) 或 SharePoint REST API 使用这些功能。These capabilities are available to administrators via PowerShell cmdlets, and to developers via the SharePoint client-side object model (CSOM) or the SharePoint REST API. 有关向单个网站集应用自定义主题的信息,请参阅 SharePoint 网站设计和网站脚本概述For information on applying custom themes to individual site collections see SharePoint site design and site script overview

有关如何使用主题自定义网站外观的一般信息,请参阅更改 SharePoint 网站的外观For general information about working with themes to customize the look of your sites, see Change the look of your SharePoint site.

默认主题Default themes

默认提供以下预定义主题:The following predefined themes are available by default:

  • 青色Teal
  • 蓝色Blue
  • 橙色Orange
  • 红色Red
  • 紫色Purple
  • 绿色Green
  • 灰色Gray
  • 深黄色(反转主题)Dark Yellow (inverted theme)
  • 深蓝色(反转主题)Dark Blue (inverted theme)

这些主题旨在提升可读性,因此非常适合用作创建自定义主题的着手点。These themes have been designed for readability, so you might find them to be useful starting points for creating custom themes. 若要详细了解默认主题,请参阅 SharePoint 网站主题:JSON 架构For more information about default themes, see SharePoint site theming: JSON schema.

除了默认主题外,还可以从补充主题中进行选择。In addition to the default themes, you can select from supplementary themes. 可以选择下列自定义:The following customizations are available:

  • 浅色主题:金色、青绿色、深蓝色、靛黑色、梅红色、暖灰色Light themes: Gold, Teal, Dark Blue, Indigo, Plum, Warm Gray
  • 深色主题:红色、绿色、紫色、灰色Dark themes: Red, Green, Purple, Gray

选择新式主题Select a modern theme

若要选择 SharePoint 网站可用的主题,请依次选择屏幕右上角的__齿轮图标 (⚙️)__ 和“更改外观”____。To select from the available themes for a SharePoint site, choose the gear icon (⚙️) in the top right corner of the screen, and then select Change the look. 此时,将会看到可供选择的主题列表,其中可能包含默认主题和/或自定义主题,具体视网站配置方式而定。You'll be presented with a list of themes to choose from, which might include default themes and/or custom themes depending on how your site has been configured.

下图展示了主题选取器对话框中显示的默认主题。The following image shows how the default themes are presented in the theme picker dialog box.


当用户在列表中选择主题后,颜色设置会立即应用于页面,以便用户预览选定主题的外观。When you choose a theme in the list, those color settings are instantly applied to the page so that you can see what the selected theme will look like.

找到要使用的主题后,可以选择“应用”以保存所做的选择,也可以选择“取消”还原为当前主题。After you've found a theme that you want to use, choose Apply to save your selection, or choose Cancel to revert to your current theme.

使用经典主题Work with classic themes

仍可使用经典主题,具体方法是在“更改外观”**** 下列出的新式主题下,选择“更改经典外观选项”**** 链接。You can still use the classic themes by choosing the link to Classic change the look options under the modern themes listed under Change the look. 虽然新式 SharePoint UI 不同于经典 UI,但对新式页面使用经典主题时,仍须遵循一些限制。Because the modern SharePoint UI differs from the classic UI, however, some limitations apply when you use classic themes with modern pages.

如果选择经典主题,将根据经典主题中的设置生成新式主题,这些设置包括 isInverted 标志、背景图像以及 ContentAccent1PageBackgroundBackgroundOverlay 的颜色设置。When you select a classic theme, a modern theme is generated from the settings in the classic theme, including the isInverted flag, the background image, and the color settings for ContentAccent1, PageBackground, and BackgroundOverlay. 如果 isInverted 设置为 True,将反转 NeutralDarkNeutralLight 等中性色。If isInverted is set to True, neutral colors such as NeutralDark and NeutralLight will be reversed.

为获得极简体验,建议对新式页面使用新式主题。For the simplest experience, we recommend that you use modern themes with modern pages. 如果需要对新式页面使用经典主题,请仔细测试站点,验证其内容的可读性和可访问性。If you need to use classic themes with modern pages, test your site carefully to verify that your content is readable and accessible.

解决自定义主题问题Troubleshoot custom theme issues

经典网站模板中也推出了新式网站主题体验。The modern site theming experience has been rolled out to classic site templates, too. 虽然新的客户端主题体系结构性能更高,但如果在更改网站主题后经典网站上的自定义主题没有正确呈现,通过禁用功能就可选择使站点退出新主题体验。While the new client-side theming architecture is more performant, if you have customizations on classic sites that aren’t rendering properly after you change the site’s theme, you can opt the site out of the new theming experience by disabling the feature. 请注意,此退出仅适用于自定义主题引用未正确呈现的经典网站。Please note, this opt-out only applies to classic sites where you have custom theme references that aren't rendering properly. 启用此网站级退出将会新式主题,并且还会失去它所提供的快速主题优势。By enabling this site-level opt-out you will disable the modern theming - and also lose the fast theming benefits it provides.

要执行此操作,必须使用由 CSOM (客户端对象模型)包装的 Windows PowerShell 脚本。To do this, you must use a Windows PowerShell script with a CSOM (client-side object model) wrapper. 我们建议使用 PnP PowerShell 启用功能命令:We recommend using the PnP PowerShell enable feature command:

  1. 确认满足以下最低要求:Verify that you meet the following minimum requirements:

    • 至少为想要禁用新式网站主题的网站上的网站集所有者You are at least a site collection owner on the site where you want to disable modern site themes
    • 已阅读执行策略You have read about Execution Policies
  2. 下载最新 PnP PowerShell。Download the latest PnP PowerShell from


    PnP PowerShell是一种开放源代码解决方案,具有活跃社区,为其提供支持。PnP PowerShell is an open-source solution with active community providing support for it. 没有用于 Microsoft 开放源代码工具支持的 SLA。There is no SLA for the open-source tool support from Microsoft.

  3. 输入 Connect-PnPOnline -Url <SiteUrl> -UseWebLogin(用你想退出的网站的 url 替换 <SiteUrl>)。Enter Connect-PnPOnline -Url <SiteUrl> -UseWebLogin (replacing <SiteUrl> with the url of the site you wish to opt out of).

  4. 出现提示时输入你的凭证信息。Enter your credentials when prompted.

  5. 若要选择退出网站,需要启用一项功能:To opt out of the site, you need to enable a feature:

    • 输入 Get-PnPFeature -Scope Site -Identity 5138468E-3D76-4F72-9DE4-E029F1245A7BEnter Get-PnPFeature -Scope Site -Identity 5138468E-3D76-4F72-9DE4-E029F1245A7B
    • 验证之前的命令没有返回任何内容(这确认了功能尚未启用)Verify that nothing is returned from the previous command (this confirms the feature isn’t enabled yet)
    • 输入 Enable-PnPFeature -Scope Site -Identity 5138468E-3D76-4F72-9DE4-E029F1245A7BEnter Enable-PnPFeature -Scope Site -Identity 5138468E-3D76-4F72-9DE4-E029F1245A7B
    • 输入 Get-PnPFeature -Scope Site -Identity 5138468E-3D76-4F72-9DE4-E029F1245A7BEnter Get-PnPFeature -Scope Site -Identity 5138468E-3D76-4F72-9DE4-E029F1245A7B
  6. 验证是否返回下列内容:Verify that the following is returned:

    ClientSideThemingOptOut - 5138468e-3d76-4f72-9de4-e029f1245a7b

有关 Windows PowerShell 的详细信息,请参阅 PowerShellFor more information about Windows PowerShell, see PowerShell.

另请参阅See also