# 在自定义主题组件中引用Discourse主题颜色变量？

**URL:** <https://meta.discourse.org/t/referencing-discourse-theme-color-variables-in-custom-theme-component/358352>\
**Category:** Support\
**Tags:** css\
**Created:** [2025年三月21日 15:42 UTC](https://meta.discourse.org/t/referencing-discourse-theme-color-variables-in-custom-theme-component/358352 "2025-03-21T15:42:10Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2025年三月21日 17:50 UTC](https://meta.discourse.org/t/referencing-discourse-theme-color-variables-in-custom-theme-component/358352/5 "2025-03-21T17:50:05Z")

</div>

我一直遇到这样的麻烦。当然，使用 `var` 是“显而易见”的，但这只有在你知晓并能记住它的时候才行！

我正在等待某事运行，所以出于好奇，我查看了 [https://ask.discourse.com/](https://ask.discourse.com/) 并提问：“是否可以在我自己的主题组件中访问 Discourse 主题颜色变量？” 结果我得到了这个：

1. **可用的颜色变量** ：  
Discourse 提供了一些预定义的颜色 CSS 自定义属性，例如：

2. **用法示例** ：  
你可以在 CSS 中使用这些变量来确保你的主题适应不同的用户选择的颜色方案。例如：

---

_[View the full topic](https://meta.discourse.org/t/referencing-discourse-theme-color-variables-in-custom-theme-component/358352)._
