# Inject CSS in Plugin

**URL:** <https://talk.getindico.io/t/inject-css-in-plugin/2574>\
**Category:** Plugin Development\
**Created:** [February 19, 2022, 8:32pm UTC](https://talk.getindico.io/t/inject-css-in-plugin/2574 "2022-02-19T20:32:41Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![donjus](https://talk.getindico.io/user_avatar/talk.getindico.io/donjus/32/897_2.png) [@donjus](https://talk.getindico.io/u/donjus)\
**Post date:** [February 19, 2022, 8:32pm UTC](https://talk.getindico.io/t/inject-css-in-plugin/2574/1 "2022-02-19T20:32:41Z")

</div>

I am currently working on implementing a plugin which is based on custom css.  
Therefore I need to inject the styles into the application. Since I am quite new to indico I am also quite clueless on how to achieve the import. I read about an inject-css function but it seems to be deprecated.  
Therefore I would be delighted if someone could help me with this topic.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![ThiefMaster](https://talk.getindico.io/user_avatar/talk.getindico.io/thiefmaster/32/509_2.png) [@ThiefMaster](https://talk.getindico.io/u/ThiefMaster)\
**Post date:** [February 19, 2022, 8:36pm UTC](https://talk.getindico.io/t/inject-css-in-plugin/2574/2 "2022-02-19T20:36:23Z")

</div>

`inject_bundle` is what you’re looking for. It’s best if you check our existing plugins on GitHub for examples…

---

<div class="post-metadata">

**Author:** ![ferus](https://talk.getindico.io/user_avatar/talk.getindico.io/ferus/32/971_2.png) [@ferus](https://talk.getindico.io/u/ferus)\
**Post date:** [May 24, 2022, 1:02pm UTC](https://talk.getindico.io/t/inject-css-in-plugin/2574/3 "2022-05-24T13:02:43Z")

</div>

Just wondering, [Search · inject\_bundle · GitHub](https://github.com/indico/indico-plugins/search?q=inject_bundle) doesn’t show any examples of injecting a CSS file, only JS files. Are there examples with CSS files as well? And is it possible to inject a CSS file only in the payment process, but not to all pages of a specific type?

---

<div class="post-metadata">

**Author:** ![ThiefMaster](https://talk.getindico.io/user_avatar/talk.getindico.io/thiefmaster/32/509_2.png) [@ThiefMaster](https://talk.getindico.io/u/ThiefMaster)\
**Post date:** [May 24, 2022, 2:04pm UTC](https://talk.getindico.io/t/inject-css-in-plugin/2574/4 "2022-05-24T14:04:04Z")

</div>

CSS and JS are handled the same way. Inject the bundle into the WP class that’s used on the page where you want to inject it.

---

<div class="post-metadata">

**Author:** ![lecabori](https://talk.getindico.io/user_avatar/talk.getindico.io/lecabori/32/835_2.png) [@lecabori](https://talk.getindico.io/u/lecabori)\
**Post date:** [September 27, 2023, 2:24pm UTC](https://talk.getindico.io/t/inject-css-in-plugin/2574/5 "2023-09-27T14:24:37Z")

</div>

Hi,  
Sorry but I don’t get it. Under my plugin folder I have a css file inside a folder as I see in the examples: “static/client/style.css” (also tried placing it just under “static/style.css”) .  
Then in my plugin class init() method I use this code:  
self.inject\_bundle(‘style.css’, WPRequestsEventManagement)  
But I don’t see my css loaded at all.  
Can you tell me what’s wrong with this? Where should I put my css and then inject it? Should it be a .css file or a .scss file?  
Thanks

---

<div class="post-metadata">

**Author:** ![bpedersen2](https://talk.getindico.io/user_avatar/talk.getindico.io/bpedersen2/32/25_2.png) [@bpedersen2](https://talk.getindico.io/u/bpedersen2)\
**Post date:** [September 29, 2023, 11:04am UTC](https://talk.getindico.io/t/inject-css-in-plugin/2574/6 "2023-09-29T11:04:03Z")

</div>

It depends what you configure in the `webpack-bundles.json`, see e.g. [https://github.com/indico/indico-plugins-cern/tree/master/vc\_assistance](https://github.com/indico/indico-plugins-cern/tree/master/vc_assistance)

---

<div class="post-metadata">

**Author:** ![bpedersen2](https://talk.getindico.io/user_avatar/talk.getindico.io/bpedersen2/32/25_2.png) [@bpedersen2](https://talk.getindico.io/u/bpedersen2)\
**Post date:** [September 29, 2023, 11:07am UTC](https://talk.getindico.io/t/inject-css-in-plugin/2574/7 "2023-09-29T11:07:02Z")

</div>

And of course you need to use the indico build-scripts (`./bin/maintenance/build-wheel.py plugin --add-version-suffix <path to your plugin>`

---

<div class="post-metadata">

**Author:** ![lecabori](https://talk.getindico.io/user_avatar/talk.getindico.io/lecabori/32/835_2.png) [@lecabori](https://talk.getindico.io/u/lecabori)\
**Post date:** [September 29, 2023, 2:14pm UTC](https://talk.getindico.io/t/inject-css-in-plugin/2574/8 "2023-09-29T14:14:50Z")

</div>

sorry, I forgot to include that in my comment. This is what I have:

```json
{
    "entry": {
      "main": "./style.css"
    }
  }

```

---

<div class="post-metadata">

**Author:** ![lecabori](https://talk.getindico.io/user_avatar/talk.getindico.io/lecabori/32/835_2.png) [@lecabori](https://talk.getindico.io/u/lecabori)\
**Post date:** [September 29, 2023, 2:18pm UTC](https://talk.getindico.io/t/inject-css-in-plugin/2574/9 "2023-09-29T14:18:26Z")

</div>

ah! this step I did not do. We don’t have an “Indico development” site (our dev server has a production install)  
I see that that script is not available to me.  
So there’s no other way I can get this css to be picked up by my plugin?  
Thanks for your response

---

<div class="post-metadata">

**Author:** ![ThiefMaster](https://talk.getindico.io/user_avatar/talk.getindico.io/thiefmaster/32/509_2.png) [@ThiefMaster](https://talk.getindico.io/u/ThiefMaster)\
**Post date:** [September 29, 2023, 2:20pm UTC](https://talk.getindico.io/t/inject-css-in-plugin/2574/10 "2023-09-29T14:20:55Z")

</div>

You MUST use a dev install to do well… development. Having a ‘dev server’ for testing is a good idea (usually people call this “staging” or “qa” though), but for actual development tasks you need to have a dev setup. Typically that’s locally on each developer’s PC or some virtual machine…

---

<div class="post-metadata">

**Author:** ![lecabori](https://talk.getindico.io/user_avatar/talk.getindico.io/lecabori/32/835_2.png) [@lecabori](https://talk.getindico.io/u/lecabori)\
**Post date:** [September 29, 2023, 2:24pm UTC](https://talk.getindico.io/t/inject-css-in-plugin/2574/11 "2023-09-29T14:24:24Z")

</div>

I understand. I am using the indico-container you’ve provided for my local development and there I can’t find the script either

---

<div class="post-metadata">

**Author:** ![ThiefMaster](https://talk.getindico.io/user_avatar/talk.getindico.io/thiefmaster/32/509_2.png) [@ThiefMaster](https://talk.getindico.io/u/ThiefMaster)\
**Post date:** [September 29, 2023, 2:26pm UTC](https://talk.getindico.io/t/inject-css-in-plugin/2574/12 "2023-09-29T14:26:55Z")

</div>

Our containers don’t work well for this: The container we publish is a production build/environment and not a development setup.

---

<div class="post-metadata">

**Author:** ![lecabori](https://talk.getindico.io/user_avatar/talk.getindico.io/lecabori/32/835_2.png) [@lecabori](https://talk.getindico.io/u/lecabori)\
**Post date:** [September 29, 2023, 2:27pm UTC](https://talk.getindico.io/t/inject-css-in-plugin/2574/13 "2023-09-29T14:27:42Z")

</div>

Got it. Thanks for your response!
