# Add class to body using Choice

**URL:** <https://community.hubspot.com/t/add-class-to-body-using-choice/68874>\
**Category:** CMS Development\
**Tags:** hubdb, css\
**Created:** [November 9, 2022, 8:27am UTC](https://community.hubspot.com/t/add-class-to-body-using-choice/68874 "2022-11-09T08:27:49Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [November 9, 2022, 2:18pm UTC](https://community.hubspot.com/t/add-class-to-body-using-choice/68874/2 "2022-11-09T14:18:47Z")

</div>

The variable you want for grabbing the data is {{ widget\_data.theme.value }}. You can also cut down on the code by using a [value, label] setup in your choice field, with the value being your class. That way instead of having an if statement you can just put the value directly into the class. Like so:

Choice (use the choice _tag_, the choice _module_ seems to be deprecated)

` {% choice "theme" label="Select a Theme", value="theme-purple_haze", choices="[[\"theme-purple_haze\", \"Purple\"], [\"theme-green_hell\", \"Green\"], [\"root-theme\", \"Yellow\"]]" %}`

Body Class

`<body class="{{ widget_data.theme.value }}">`

If you wanted to use a custom module instead you could set the class using javascript from within the module.

```lia-code-sample
<script>
 document.querySelector('body').classList.add({{ module.theme|tojson }});
</script>

```

---

_[View the full topic](https://community.hubspot.com/t/add-class-to-body-using-choice/68874)._
