# Codeblock Theme Picker

**URL:** https://meta.discourse.org/t/codeblock-theme-picker/146396
**Category:** Theme component
**Tags:** official, codeblock-theme-picker
**Created:** [April 1, 2020, 6:53am UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396 "2020-04-01T06:53:35Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [April 1, 2020, 6:53am UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/1 "2020-04-01T06:53:35Z")

</div>

| | | |
| --- | --- | --- |
| :discourse2: | **Summary** | **Codeblock Theme Picker** will allow you to easily change the theme used in code blocks. |
| 👓 | **Preview** | [Preview on Discourse Theme Creator](https://discourse.theme-creator.io/theme/Discourse/codeblock-theme-picker) |
| 🛠 | **Repository Link** | [https://github.com/discourse/hljs-theme-picker](https://github.com/discourse/hljs-theme-picker) |
| 📖 | **New to Discourse Themes?** | [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) |

Install this theme component

> [@](#):
>
> :discourse2: As this is an #official theme component maintained by the Discourse team, #Support, #Contribute > Bug, #Contribute > UX, and #Contribute > Feature requests can be made in the respective categories here on Meta, and tagged with the appropriate theme component tag. Click on a link below to get one started. 👍
> 
> [❓&nbsp; **Support**](https://meta.discourse.org/new-topic?category_id=6&tags=codeblock-theme-picker "Ask for support on configuring and using Codeblock Theme Picker") [🐛&nbsp; **Bug**](https://meta.discourse.org/new-topic?category_id=1&tags=codeblock-theme-picker "A bug report means something is broken, preventing normal/typical use of the theme component") [👀&nbsp; **UX**](https://meta.discourse.org/new-topic?category_id=9&tags=codeblock-theme-picker "Discussion about the user interface of Codeblock Theme Picker, and how features are presented (including language and UI elements)") [💡&nbsp; **Feature**](https://meta.discourse.org/new-topic?category_id=2&tags=codeblock-theme-picker "Discussion about how existing Codeblock Theme Picker features can be improved or enhanced, and how proposed new features could work")

### Features

 ![Some examples of the colors available](https://global.discourse-cdn.com/meta/original/3X/3/e/3e627f0d3cc4343172abba8e8a1b7ed5b7c58b59.png)

This is just a handful of the available options. This component includes [all 90 options](https://highlightjs.org/static/demo/) offered in the hljs repository.

> ℹ While all the options are included in this component, it will only load the one you pick. So, there’s no overhead.

### How to use it

Due to the way this component is wired up, it will require a small change to one of your site settings.

1. Head to `your.site.com/admin/site_settings/`
2. Search for `theme_authorized_extensions`
3. Add `css` to that list.

Like so:

 ![add css to theme authorized extensions](https://global.discourse-cdn.com/meta/original/3X/a/4/a4fc401af2a0cf3ea31c6bf31a1c35f129ea79c6.png)

⚠ You have to do this before you install the component, otherwise it won’t work.

Once that’s done, you can install the component just like any other component.

### Settings

| Name | Description |
| --- | --- |
| hljs theme | Select the theme you want code blocks to use. You can visit [the hljs demo page](https://highlightjs.org/static/demo/) to preview the themes |
| hljs dark match | Load dark color scheme if available |

If you need to see what the options look like, have a look here [We're not a CDN - highlight.js](https://highlightjs.org/static/demo/)

Once you decide on a hljs theme to use, you can search the dropdown for the one you want and save the setting. You will need to refresh the page in order for everything to start working.

### Credits

All of the hljs themes included in this component have copyright information in their respective files. The list of all of those authors (❤) is too big to add here, but you can see them [here](https://github.com/discourse/hljs-theme-picker/tree/master/assets).

  

> :discourse2: **Hosted by us?** Theme components are available to use on our Standard, Business, and Enterprise plans.

> Last edited by @JammyDodger 2024-06-11T13:25:37Z
> 
> > **Check document**
> >
> > Perform check on document:

---

<div class="post-metadata">

### Author: ![MuZhou233](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/muzhou233/32/211433_2.png) [@MuZhou233](https://meta.discourse.org/u/MuZhou233)
#### Post date: [February 28, 2021, 12:01pm UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/16 "2021-02-28T12:01:37Z")

</div>

This theme is very useful and running in my site for a long time. How ever I suddenly found it has a problem on firefox. The custom css file blocked by the following header `X-Content-Type-Options: nosniff`. Console shows that css file MIME type is text/html. No matter which theme I choise the problem still happen on firefox but chrome is fine.

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [February 28, 2021, 1:48pm UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/17 "2021-02-28T13:48:24Z")

</div>

This super theme component would be even better if the selected codeblock style was also selectable as a user preference.

---

<div class="post-metadata">

### Author: ![Zup](https://avatars.discourse-cdn.com/v4/letter/z/c37758/32.png) [@Zup](https://meta.discourse.org/u/Zup)
#### Post date: [August 28, 2021, 10:15pm UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/18 "2021-08-28T22:15:17Z")

</div>

Seconded. As user preference would be very cool.

---

<div class="post-metadata">

### Author: ![Reaxgrim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/reaxgrim/32/233033_2.png) [@Reaxgrim](https://meta.discourse.org/u/Reaxgrim)
#### Post date: [September 4, 2021, 2:12am UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/19 "2021-09-04T02:12:10Z")

</div>

Anyway to show line numbers?

---

<div class="post-metadata">

### Author: ![SkyLin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/skylin/32/206593_2.png) [@SkyLin](https://meta.discourse.org/u/SkyLin)
#### Post date: [October 29, 2021, 3:56am UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/20 "2021-10-29T03:56:23Z")

</div>

> [@Johani](#):
>
> This component includes [all 90 options](https://highlightjs.org/static/demo/) offered in the hljs repository.

Great theme component.

One question, there are 242 themes on [highlight.js demo](https://highlightjs.org/static/demo/). For example, “Github Dark Dimmed” as attached image.

Is there any way to solve this issue? Thanks for advice.

 ![highlight.js demo](https://global.discourse-cdn.com/meta/original/3X/8/b/8bd5b5a0f33b47209ae538dcd08b73aaeef1588f.png)

---

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [October 29, 2021, 8:05am UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/21 "2021-10-29T08:05:16Z")

</div>

> [@SkyLin](#):
>
> there are 242 themes on [highlight.js demo](https://highlightjs.org/static/demo/)

Unfortunately, this is a little bit involved.

Discourse runs version 10.6.0 of highlight-js. Most of the extra themes missing right now - base16 - require version 11.0

The issue is that that version introduces some breaking changes and deprecations. Have a look here

[Release Version 11 · highlightjs/highlight.js · GitHub](https://github.com/highlightjs/highlight.js/releases/tag/11.0.0)

So, this means that the current options are going to stay the same for a while. First, the highlight-js version needs to be updated in `tests-passed` in Discourse. Then we’d need to wait for a stable release. Updating the themes (even the current ones) would put us in a bad state where it’s guesswork whether the theme works properly on your site or not.

---

<div class="post-metadata">

### Author: ![vincentp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vincentp/32/110063_2.png) [@vincentp](https://meta.discourse.org/u/vincentp)
#### Post date: [August 2, 2022, 2:11am UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/22 "2022-08-02T02:11:35Z")

</div>

This component seems to be broken in the latest betas - highlighting no longer works correctly when it’s installed. I removed the component from the themes and it started working again - I just don’t get to chose the highlighting theme.

---

<div class="post-metadata">

### Author: ![erisdisqordia](https://avatars.discourse-cdn.com/v4/letter/e/71c47a/32.png) [@erisdisqordia](https://meta.discourse.org/u/erisdisqordia)
#### Post date: [September 3, 2022, 4:34am UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/23 "2022-09-03T04:34:42Z")

</div>

confirm syntax highlighting is broken here too on the latest beta

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [September 20, 2022, 3:53pm UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/24 "2022-09-20T15:53:46Z")

</div>

@Falco just merged a fix for this component: [DEV: Update highlight.js to version 11 by xfalcox · Pull Request #3 · discourse/hljs-theme-picker · GitHub](https://github.com/discourse/hljs-theme-picker/pull/3)

It includes an update to highlight.js version 11 themes (core has [been updated](https://github.com/discourse/discourse/pull/18282) to highlight.js version 11 too) and fixes for styles missing the correct specificity.

---

<div class="post-metadata">

### Author: ![Dennis\_P\_Z](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dennis_p_z/32/330504_2.png) [@Dennis\_P\_Z](https://meta.discourse.org/u/Dennis_P_Z)
#### Post date: [October 23, 2023, 9:36pm UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/25 "2023-10-23T21:36:56Z")

</div>

I got this error when I tried to install the component

```plaintext
Error creating upload asset: a11y-dark. Original filename Sorry, the file you are trying to upload is not authorized (authorized extensions: wasm, jpg, jpeg, png, woff, woff2, svg, eot, ttf, otf, gif, webp, avif, js).

```

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [October 24, 2023, 7:16am UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/26 "2023-10-24T07:16:24Z")

</div>

Did you do this bit 👇

> [@jordan-vidrine](#):
>
> Due to the way this component is wired up, it will require a small change to one of your site settings.
> 
> 1. head to `your.site.com/admin/site_settings/`
> 2. search for `theme_authorized_extensions`
> 3. add `css` to that list.
> 
> Like so:
> 
> ![add css to theme authorized extensions](https://global.discourse-cdn.com/meta/original/3X/a/4/a4fc401af2a0cf3ea31c6bf31a1c35f129ea79c6.png)
> 
> ⚠ You have to do this before you install the component, otherwise it won’t work.

---

<div class="post-metadata">

### Author: ![Dennis\_P\_Z](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dennis_p_z/32/330504_2.png) [@Dennis\_P\_Z](https://meta.discourse.org/u/Dennis_P_Z)
#### Post date: [October 24, 2023, 7:31am UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/27 "2023-10-24T07:31:07Z")

</div>

Ooh noo, I’m going to do that 🤗

---

<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: [May 15, 2024, 5:17pm UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/28 "2024-05-15T17:17:32Z")

</div>

Just found this theme component—so glad this exists! I notice that the setting `hljs dark match` does not seem to work.

For example, we have `hljs theme` set to `atom-one-light` (to which there also exists, `atom-one-dark`).

Upon refreshing, the `atom-one-light` takes while in dark mode, but the code block does not switch to dark when switching to dark mode—it stays as light.

---

<div class="post-metadata">

### Author: ![hoangphuctran93](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hoangphuctran93/32/290976_2.png) [@hoangphuctran93](https://meta.discourse.org/u/hoangphuctran93)
#### Post date: [June 3, 2024, 3:35pm UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/29 "2024-06-03T15:35:15Z")

</div>

![This image displays an error message stating that the file being uploaded is not an authorized file type or extension for that particular upload process. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/b/8/b/b8b39f04ad90e817d37fb1bc53c3ea44fbb774d4.png)  
I received this error message when installing theme components, hoping someone could guide the community on how to fix them

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [June 3, 2024, 3:45pm UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/30 "2024-06-03T15:45:42Z")

</div>

Did you add `css` to the allowed theme extensions list?

> [@jordan-vidrine](#):
>
> Due to the way this component is wired up, it will require a small change to one of your site settings.
> 
> 1. head to `your.site.com/admin/site_settings/`
> 2. search for `theme_authorized_extensions`
> 3. add `css` to that list.
> 
> Like so:
> 
> ![add css to theme authorized extensions](https://global.discourse-cdn.com/meta/original/3X/a/4/a4fc401af2a0cf3ea31c6bf31a1c35f129ea79c6.png)
> 
> ⚠ You have to do this before you install the component, otherwise it won’t work.

---

<div class="post-metadata">

### Author: ![hoangphuctran93](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hoangphuctran93/32/290976_2.png) [@hoangphuctran93](https://meta.discourse.org/u/hoangphuctran93)
#### Post date: [June 3, 2024, 4:39pm UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/31 "2024-06-03T16:39:28Z")

</div>

Thank you, it work ^^

---

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [November 12, 2024, 2:52am UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/32 "2024-11-12T02:52:23Z")

</div>

Note:

> [@Discourse](#):
>
> visit [the hljs demo page](https://highlightjs.org/static/demo/) to

> [@Discourse](#):
>
> look here [We’re not a CDN - highlight.js](https://highlightjs.org/static/demo/)

It should be:

> [@Update or remove highlight.js demo link](https://meta.discourse.org/t/update-or-remove-highlight-js-demo-link/304538/1):
>
> the link should be [Demo - highlight.js](https://highlightjs.org/demo)

---

<div class="post-metadata">

### Author: ![cnlanny](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cnlanny/32/502397_2.png) [@cnlanny](https://meta.discourse.org/u/cnlanny)
#### Post date: [January 19, 2026, 11:37am UTC](https://meta.discourse.org/t/codeblock-theme-picker/146396/33 "2026-01-19T11:37:31Z")

</div>

**It seems that this theme component is broken in the latest version.**

**I have already added `css` to the `theme_authorized_extensions` setting and tried reinstalling the component, but the code block styles are still not applying.**

**Could you please verify this? Thanks.**
