# 如何为调色板添加更多选项？

**URL:** <https://meta.discourse.org/t/how-to-add-more-options-to-color-palettes/378547>\
**Category:** Support\
**Tags:** color-palettes\
**Created:** [2025年八月14日 08:01 UTC](https://meta.discourse.org/t/how-to-add-more-options-to-color-palettes/378547 "2025-08-14T08:01:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alltiagocom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alltiagocom/32/492709_2.png) [@alltiagocom](https://meta.discourse.org/u/alltiagocom)\
**Post date:** [2025年八月14日 08:01 UTC](https://meta.discourse.org/t/how-to-add-more-options-to-color-palettes/378547/1 "2025-08-14T08:01:05Z")

</div>

我注意到有些调色板比其他调色板有更多的颜色设置选项。  
例如，Dracula 调色板比其他调色板有更多的选项。

我看到了这个帖子，但不确定是否相关：

> [@Why might dark-light-choose() not work?](https://meta.discourse.org/t/why-might-dark-light-choose-not-work/172232/2?u=alltiagocom):
>
> I believe, due to the way the SCSS is compiled, custom dark/light definitions need to be added to color\_definitions.scss within a theme and won’t work in other scss files. color\_definitions.scss is high up in the cascade (before a lot of the default styles), so you don’t want to add the .modal.history-modal ins part there. Instead you can just add the color definition itself… $dark-theme-ins: #acf2bd; $light-theme-ins: #4da06d; $ins: dark-light-choose(…

这似乎与主题有关，但调色板没有编辑代码和添加颜色定义的选项。

---

<div class="post-metadata">

**Author:** ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)\
**Post date:** [2025年八月14日 15:37 UTC](https://meta.discourse.org/t/how-to-add-more-options-to-color-palettes/378547/2 "2025-08-14T15:37:52Z")

</div>

是的，主题可以直接覆盖单个颜色——这无法通过调色板管理区域实现

> [@Override values for auto-generated color variables](https://meta.discourse.org/t/override-values-for-auto-generated-color-variables/134374):
>
> As of v2.3.3 (released early September) you can now override our automatically-generated SASS color variables ($primary-low, $primary-medium, etc) in remote themes (you can not yet do this directly via the admin UI.) To override one of these colors you need to add it to the color\_scheme section of your theme’s about.json file. Once you’ve done that you can see the override listed within your color scheme in /admin/customize/colors. "color\_schemes": { “My\_colors”: { "primary": "000000…

---

<div class="post-metadata">

**Author:** ![alltiagocom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alltiagocom/32/492709_2.png) [@alltiagocom](https://meta.discourse.org/u/alltiagocom)\
**Post date:** [2025年八月14日 17:16 UTC](https://meta.discourse.org/t/how-to-add-more-options-to-color-palettes/378547/3 "2025-08-14T17:16:10Z")

</div>

谢谢分享。

那么，对于还不熟悉这些内容的人来说，是不是意味着我需要SSH到我的服务器（如果术语是这样的话？）然后找到那个json文件，进行修改，这样UI就会反映出来？

如果是这样的话，我们就可以覆盖默认变量，也可以添加新的变量，对吗？

---

<div class="post-metadata">

**Author:** ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)\
**Post date:** [2025年八月14日 18:04 UTC](https://meta.discourse.org/t/how-to-add-more-options-to-color-palettes/378547/4 "2025-08-14T18:04:03Z")

</div>

> [@alltiagocom](#):
>
> 那意味着我需要 SSH 到我的服务器（如果术语正确的话？）并找到那个 json 文件，进行更改，然后它就会反映在 UI 中？

如果你这样做，我认为它可能会被下一次 Discourse 更新覆盖……所以通常你应该保持现有的调色板不变

如果你想创建一个包含所有扩展颜色覆盖的新调色板，并使其可供用户选择，最简单的方法是创建一个主题并上传它。

你只需要在主题本身中编辑 about.json 以包含颜色定义……这里有一个例子：

> <https://github.com/dracula/discourse/blob/master/about.json#L18>

一旦主题被添加到站点，包含的颜色调色板将被添加到 `admin/customize/colors`，你可以使其可供用户选择

自定义我们颜色的另一种方法是直接用 CSS 覆盖它们，这需要使用某个主题而不是特定的颜色调色板……但在主题的 common 文件中你可以这样做：

```css
:root {
  --primary-low: red;
  --secondary: #ff0000;
}

```

通过打开浏览器检查器，单击顶部的 HTML 元素，然后滚动一些（我们现在有很多变量），你可以看到所有可用的颜色进行覆盖

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/c/1/dc1fa6663a5d066d966ea447224f4739078d8488.png)

这种方法的优点是你可以通过管理 UI 中的主题编辑器来完成它

---

<div class="post-metadata">

**Author:** ![alltiagocom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alltiagocom/32/492709_2.png) [@alltiagocom](https://meta.discourse.org/u/alltiagocom)\
**Post date:** [2025年八月15日 08:50 UTC](https://meta.discourse.org/t/how-to-add-more-options-to-color-palettes/378547/5 "2025-08-15T08:50:05Z")

</div>

这里有很多内容需要消化，但我一定会花时间阅读、分析和测试它。

非常感谢您如此详尽的回复。我已将其保存到我的笔记中。🙌
