# Referencing Discourse theme color variables in custom theme component?

**URL:** https://meta.discourse.org/t/referencing-discourse-theme-color-variables-in-custom-theme-component/358352
**Category:** Support
**Tags:** css
**Created:** [March 21, 2025, 3:42pm 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:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jordan-violet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan-violet/32/281428_2.png) [@jordan-violet](https://meta.discourse.org/u/jordan-violet)
#### Post date: [March 21, 2025, 3:42pm UTC](https://meta.discourse.org/t/referencing-discourse-theme-color-variables-in-custom-theme-component/358352/1 "2025-03-21T15:42:10Z")

</div>

Is it possible to access Discourse theme color variables in my own theme component?

I’m trying to use variables like `--secondary` in my CSS and it doesn’t seem to be working.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [March 21, 2025, 3:48pm UTC](https://meta.discourse.org/t/referencing-discourse-theme-color-variables-in-custom-theme-component/358352/3 "2025-03-21T15:48:41Z")

</div>

Yes, you should be able to access core’s native-css variables from a theme or theme component 👍

e.g.

```plaintext
body {
  background-color: var(--secondary);
}

```

Could you share an example that’s not working?

---

<div class="post-metadata">

### Author: ![jordan-violet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan-violet/32/281428_2.png) [@jordan-violet](https://meta.discourse.org/u/jordan-violet)
#### Post date: [March 21, 2025, 4:16pm UTC](https://meta.discourse.org/t/referencing-discourse-theme-color-variables-in-custom-theme-component/358352/4 "2025-03-21T16:16:23Z")

</div>

Ah! I wasn’t using `var()`

---

<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: [March 21, 2025, 5:50pm UTC](https://meta.discourse.org/t/referencing-discourse-theme-color-variables-in-custom-theme-component/358352/5 "2025-03-21T17:50:05Z")

</div>

I have trouble like this all the time. Sure, it’s “obvious” to use `var`, but only if you know and can remember!

i’m waiting for something to run, so out of curiosity I checked [https://ask.discourse.com/](https://ask.discourse.com/) and asked “Is it possible to access Discourse theme color variables in my own theme component?” and lo! I got this:

1. **Available Color Variables** :  
Discourse provides several predefined CSS custom properties for colors, such as:

2. **Example Usage** :  
You can use these variables in your CSS to ensure your theme adapts to different user-selected color schemes. For instance:

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [April 20, 2025, 5:50pm UTC](https://meta.discourse.org/t/referencing-discourse-theme-color-variables-in-custom-theme-component/358352/6 "2025-04-20T17:50:18Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
