[comment]: # ({d1036ff8-d1036ff8})
# 8 创建自定义主题

[comment]: # ({/d1036ff8-d1036ff8})

[comment]: # ({cb54c172-cb54c172})
#### 概述

默认情况下，Zabbix提供了多种预定义主题。您可以按照此处提供的分步指南来create自己的主题。如果您创建了出色的主题，欢迎与Zabbix社区分享您的工作成果。

[comment]: # ({/cb54c172-cb54c172})

[comment]: # ({be6afd90-be6afd90})
##### 步骤1

要定义自定义主题，您需要create一个CSSfile并将其保存到
`assets/styles/`文件夹中（例如*custom-theme.css*）。您可以选择
copy其他主题的文件并基于此create您的主题，或者从头开始创建。

[comment]: # ({/be6afd90-be6afd90})

[comment]: # ({34bae249-34bae249})
##### 步骤 2

将您的主题添加到APP::getThemes()方法返回的主题列表中。您可以通过在APP类中重写ZBase::getThemes()方法来实现。具体操作是在*include/classes/core/APP.php*文件的右大括号前添加以下代码：

      public static function getThemes() {
          return array_merge(parent::getThemes(), [
              'custom-theme' => _('Custom theme')
          ]);
      }

::: noteimportant
请注意，第一对引号内指定的名称必须与主题file的名称（不含扩展名）完全匹配。

:::

若要添加多个主题，只需在第一个主题下方列出它们，例如：

      public static function getThemes() {
          return array_merge(parent::getThemes(), [
              'custom-theme' => _('Custom theme'),
              'anothertheme' => _('Another theme'),
              'onemoretheme' => _('One more theme')
          ]);
      }

注意：除最后一个主题外，每个主题末尾都必须有逗号。

::: notetip
要更改图表颜色，必须在*graph\_theme*数据库表中添加相应条目。

:::

[comment]: # ({/34bae249-34bae249})

[comment]: # ({b67ccba3-b67ccba3})
##### 步骤3

激活新主题.

在Zabbix前端中，您可以将此主题设置为默认主题
或在用户配置文件中更改您的主题.

享受全新的外观体验!

[comment]: # ({/b67ccba3-b67ccba3})
