# Add CurrentThemeId into Body Css Classes

**URL:** https://meta.discourse.org/t/add-currentthemeid-into-body-css-classes/161380
**Category:** Support
**Created:** [August 19, 2020, 2:52pm UTC](https://meta.discourse.org/t/add-currentthemeid-into-body-css-classes/161380 "2020-08-19T14:52:37Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![nildarar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nildarar/32/331927_2.png) [@nildarar](https://meta.discourse.org/u/nildarar)
#### Post date: [August 19, 2020, 2:52pm UTC](https://meta.discourse.org/t/add-currentthemeid-into-body-css-classes/161380/1 "2020-08-19T14:52:37Z")

</div>

Hi,  
Can anybody help me to add active theme id as `<html>` or `<body>` CSS class?  
I need to write some styles and need different attributes for some themes.

For example when using “ **dark-theme** ”:

```
<html class="desktop-view not-mobile-device text-size-normal dark-theme">

```

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [August 20, 2020, 2:47am UTC](https://meta.discourse.org/t/add-currentthemeid-into-body-css-classes/161380/2 "2020-08-20T02:47:20Z")

</div>

We don’t use the name as an ID, just a number. You can find a theme’s ID by looking at the URL when you’re customizing a theme in the admin panel… for example `https://forum.example.come/admin/customize/themes/140`

If you can get by with the ID and not the name, this would be a quick way to do it (added to your theme/component’s head file):

```xml
<script type="text/discourse-plugin" version="0.8">
  var themeSelector = require('discourse/lib/theme-selector');
  document.querySelector("body").classList.add("theme-id-" + themeSelector.currentThemeId())
</script>

```

You could also find the theme name by ID, but it would take a little more work.

---

<div class="post-metadata">

### Author: ![nildarar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nildarar/32/331927_2.png) [@nildarar](https://meta.discourse.org/u/nildarar)
#### Post date: [August 20, 2020, 5:18am UTC](https://meta.discourse.org/t/add-currentthemeid-into-body-css-classes/161380/3 "2020-08-20T05:18:22Z")

</div>

Thanks, Kris, @awesomerobot  
Is there any document for discourse plugin and related libs methods?

I found this but it seems not to include all libs and methods:

> [@Developing Discourse Themes & Theme Components](https://meta.discourse.org/t/developer-s-guide-to-discourse-themes/93648#heading--4-c):
>
> Discourse Themes and Theme Components can be used to customize the look, feel and functionality of Discourse’s frontend. This section of the developer guides aims to provide all the reference materials you need to develop simple themes for a single site, right up to complex open-source theme components. This introduction aims to provide a map of all the tools and APIs for theme development. If you prefer a step-by-step tutorial for theme development, jump straight to: Themes vs. Theme Compon…

---

<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: [September 19, 2020, 5:32am UTC](https://meta.discourse.org/t/add-currentthemeid-into-body-css-classes/161380/4 "2020-09-19T05:32:52Z")

</div>

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