# 颜色是如何工作的以及如何更改它们？

**URL:** <https://meta.discourse.org/t/how-do-colors-work-and-how-to-change-them/358122>\
**Category:** Support\
**Tags:** ux\
**Created:** [2025年三月20日 10:12 UTC](https://meta.discourse.org/t/how-do-colors-work-and-how-to-change-them/358122 "2025-03-20T10:12:15Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)\
**Post date:** [2025年三月20日 11:15 UTC](https://meta.discourse.org/t/how-do-colors-work-and-how-to-change-them/358122/3 "2025-03-20T11:15:01Z")

</div>

> [@pHneutre](#):
>
> 但随后我迷失了，因为我发现了像 `var(--primary-low)` 这样的东西，我不知道它们在哪里定义

颜色在这里（计算）:

> <https://github.com/discourse/discourse/blob/main/app/assets/stylesheets/common/foundation/color_transformations.scss>

CSS 变量在这里定义:

> <https://github.com/discourse/discourse/blob/main/app/assets/stylesheets/color_definitions.scss>

如果你想覆盖比如 `--primary-medium`，你可以在你的主题中添加这个:

```scss
:root {
    --primary-high: red;
}

```

但是，我不知道如何使用 [颜色转换函数](https://github.com/discourse/discourse/blob/main/app/assets/stylesheets/common/foundation/variables.scss)，这需要 SCSS 变量。

我看到 `@import "common/foundation/variables";` 不是必需的，因为 [“核心和主题变量现在在任何 SCSS 文件编译之前注入”](https://meta.discourse.org/t/enhanced-category-box-display-component/156954/7?u=canapin)，但我仍然无法让它工作。我将把话筒交给更有知识的用户 🎤

---

_[View the full topic](https://meta.discourse.org/t/how-do-colors-work-and-how-to-change-them/358122)._
