# Cannot access theme.header.background.color

**URL:** <https://community.hubspot.com/t/cannot-access-theme-header-background-color/61373>\
**Category:** CMS Development\
**Tags:** free\
**Created:** [July 20, 2022, 5:29pm UTC](https://community.hubspot.com/t/cannot-access-theme-header-background-color/61373 "2022-07-20T17:29:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![paladinodeimari](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/paladinodeimari/32/14679_2.png) [@paladinodeimari](https://community.hubspot.com/u/paladinodeimari)\
**Post date:** [July 20, 2022, 5:29pm UTC](https://community.hubspot.com/t/cannot-access-theme-header-background-color/61373/1 "2022-07-20T17:29:15Z")

</div>

This is a piece of my fields.json:

```lia-code-sample
{
 "label": "Website header",
 "name": "header",
 "type": "group",
 "children": [
 {
 "label": "Background",
 "name": "background",
 "type": "group",
 "children": [
 {
 "label": "Color",
 "name": "color",
 "type": "color",
 "required" : true
 }
 ]
 }
 ]
 }

```

I’m trying to get the value of backround color but I get a wrong content.

Inside my css:

```lia-code-sample
.header {
 background-color: {{ theme.header.background.color }}
}

```

In Chrome inspector I get:

```lia-code-sample
.header {
 background-color: {color=null,opacity=null,show_opacity=null,css=};
}

```

What’s wrong?

---

<div class="post-metadata">

**Author:** ![Oezcan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/oezcan/32/53959_2.png) [@Oezcan](https://community.hubspot.com/u/Oezcan)\
**Post date:** [July 21, 2022, 8:20am UTC](https://community.hubspot.com/t/cannot-access-theme-header-background-color/61373/2 "2022-07-21T08:20:48Z")

</div>

Hello @paladinodeimari ,

The color value is missing in your object:

Here is a simple example:

```lia-code-sample
{
"name": "color_field",
"label": "Color field",
"required": false,
"locked": false,
"inline_help_text": "",
"help_text": "",
"type": "color",
"default": {
 "color": "#ffffff",
 "opacity": 100 }
}

```

This is how you get the color and can “shorten” it

`{% set bg_color = theme.color_field.color %}`

And this is how you can then assign the color to it.

```lia-code-sample
header {
 background-color: {{ bg_color }}
}

```

That’s all 🙂

I hope I could help you.

Best regards

Özcan

---

<div class="post-metadata">

**Author:** ![paladinodeimari](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/paladinodeimari/32/14679_2.png) [@paladinodeimari](https://community.hubspot.com/u/paladinodeimari)\
**Post date:** [July 21, 2022, 8:48am UTC](https://community.hubspot.com/t/cannot-access-theme-header-background-color/61373/3 "2022-07-21T08:48:05Z")

</div>

Thank You Özcan.

I try what you suggested but I’ve still problem.

I put in fields.json the cut and paste of your code:

```lia-code-sample
{
 "label": "Background",
 "name": "background",
 "type": "group",
 "children": [
 { "name": "color_field", "label": "Color field", "required": false, "locked": false, "inline_help_text": "", "help_text": "", "type": "color", "default": { "color": "#ffffff", "opacity": 100 } }
 ]
 }

```

Then in my css:

```lia-code-sample
{% set bg_color = theme.color_field.color %}

.header { background-color: {{ bg_color }} }

```

But now this is what I get in inspector:

```lia-code-sample
.header {
 background-color: rgba(#null,1);
}

```

And if I open the css within the browser it doesn’t contain the code .header!

I have published all the modified files.

---

<div class="post-metadata">

**Author:** ![Oezcan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/oezcan/32/53959_2.png) [@Oezcan](https://community.hubspot.com/u/Oezcan)\
**Post date:** [July 21, 2022, 8:54am UTC](https://community.hubspot.com/t/cannot-access-theme-header-background-color/61373/4 "2022-07-21T08:54:54Z")

</div>

Ah,

then you need something like this:

`{%- set bg_color = 'rgba(' + theme.color_field.color|convert_rgb + ", " + theme.color_field.opacity/100 + ')' %}`

---

<div class="post-metadata">

**Author:** ![paladinodeimari](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/paladinodeimari/32/14679_2.png) [@paladinodeimari](https://community.hubspot.com/u/paladinodeimari)\
**Post date:** [July 21, 2022, 9:04am UTC](https://community.hubspot.com/t/cannot-access-theme-header-background-color/61373/5 "2022-07-21T09:04:43Z")

</div>

Done but still doesn’t work.

Cannot understand why!

![](https://d2qpr2jzcazej7.cloudfront.net/optimized/3X/d/e/dedda18516f1b9aad1d491bc4737d96a29a81385_2_690x97.png)

 ![paladinodeimari_1-1658394223429.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/d/dd8d988fac80e7852215cc9c9583822f28364772.png)

The point is that I’m using color for other elements and in that case it works.

![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/d/2/d2b8895b85d4905d97cb42e0d792304863a7c6e3.png)

---

<div class="post-metadata">

**Author:** ![Oezcan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/oezcan/32/53959_2.png) [@Oezcan](https://community.hubspot.com/u/Oezcan)\
**Post date:** [July 21, 2022, 10:07am UTC](https://community.hubspot.com/t/cannot-access-theme-header-background-color/61373/6 "2022-07-21T10:07:18Z")

</div>

What I just noticed is that if the color\_field is packed in a group, the group must also be addressed. So not

{% set bg\_color = theme.color\_field.color %}

but

{% set bg\_color = theme.background.color\_field.color %}

 ![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/6/0/60287536cdae866a93130dce1d10f5033f3f4454.png)
