# Panel custom css bug

**URL:** https://forum.getkirby.com/t/panel-custom-css-bug/23011
**Category:** Questions
**Tags:** v3
**Created:** [July 28, 2021, 11:11am UTC](https://forum.getkirby.com/t/panel-custom-css-bug/23011 "2021-07-28T11:11:17Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![SoraK](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sorak/32/10692_2.png) [@SoraK](https://forum.getkirby.com/u/SoraK)
#### Post date: [July 28, 2021, 11:11am UTC](https://forum.getkirby.com/t/panel-custom-css-bug/23011/1 "2021-07-28T11:11:17Z")

</div>

Hi, the config below is still not working.

```auto
return [
  'panel' => [
    'css' => 'assets/css/custom-panel.css'
  ]
];

```

i found some code for custom js in the kirby core /kirby/views/panel.php like this:

```auto
<?php if (isset($config['js'])) : ?>
    <script nonce="<?= $nonce ?>" src="<?= Url::to($config['js']) ?>" defer></script>
  <?php endif ?>

```

But for custom css the code block isn’t there.  
Is this a bug in kirby 3.5.7?

So… if i add this code block to the panel.php the config for custom css works:

```auto
<?php if (isset($config['css'])) : ?>
      <link nonce="<?= $nonce ?>" rel="stylesheet" href="<?= Url::to($config['css']) ?>">
 <?php endif ?>

```

---

<div class="post-metadata">

### Author: ![pixelijn](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@pixelijn](https://forum.getkirby.com/u/pixelijn)
#### Post date: [July 28, 2021, 12:24pm UTC](https://forum.getkirby.com/t/panel-custom-css-bug/23011/2 "2021-07-28T12:24:23Z")

</div>

> [@SoraK](#):
>
> Is this a bug in kirby 3.5.7?

No, definitely not.

Do you have more in your config.php then this one return statement?

---

<div class="post-metadata">

### Author: ![SoraK](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sorak/32/10692_2.png) [@SoraK](https://forum.getkirby.com/u/SoraK)
#### Post date: [July 28, 2021, 12:25pm UTC](https://forum.getkirby.com/t/panel-custom-css-bug/23011/3 "2021-07-28T12:25:02Z")

</div>

Hi, yes in my config is also an array key for hooks and the debug mode is enabled

---

<div class="post-metadata">

### Author: ![pixelijn](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@pixelijn](https://forum.getkirby.com/u/pixelijn)
#### Post date: [July 28, 2021, 12:26pm UTC](https://forum.getkirby.com/t/panel-custom-css-bug/23011/4 "2021-07-28T12:26:44Z")

</div>

That’s exactly the problem: you can only have one return statement. Everything afte the first return is ignored. You can read about return here: [PHP: return - Manual](https://www.php.net/manual/en/function.return.php)

---

<div class="post-metadata">

### Author: ![SoraK](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sorak/32/10692_2.png) [@SoraK](https://forum.getkirby.com/u/SoraK)
#### Post date: [July 28, 2021, 12:28pm UTC](https://forum.getkirby.com/t/panel-custom-css-bug/23011/5 "2021-07-28T12:28:58Z")

</div>

Oh sorry, i misunderstood your answer…  
No there is not more than one return statement… but the config array has more keys…

```auto
array(4) {
  ["debug"]=>
  bool(true)
  ["panel"]=>
  array(1) {
    ["css"]=>
    string(27) "assets/css/custom-panel.css"
  }
  ["api"]=>
  array(1) {
    ["csrf"]=>
    string(4) "test"
  }
  ["hooks"]=>
  array(3) {
    ["user.create:after"]=>
    object(Closure)#50 (1) {
      ["parameter"]=>
      array(1) {
        ["$user"]=>
        string(10) "<required>"
      }
    }
    ["user.update:after"]=>
    object(Closure)#49 (1) {
      ["parameter"]=>
      array(2) {
        ["$newUser"]=>
        string(10) "<required>"
        ["$oldUser"]=>
        string(10) "<required>"
      }
    }
    ["user.login:after"]=>
    object(Closure)#48 (1) {
      ["parameter"]=>
      array(2) {
        ["$user"]=>
        string(10) "<required>"
        ["$session"]=>
        string(10) "<required>"
      }
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![pixelijn](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@pixelijn](https://forum.getkirby.com/u/pixelijn)
#### Post date: [July 28, 2021, 12:41pm UTC](https://forum.getkirby.com/t/panel-custom-css-bug/23011/6 "2021-07-28T12:41:31Z")

</div>

> [@SoraK](#):
>
> ` string(27) "assets/css/custom-panel.css"`

Oh, ok. And the file exists at the given location?

---

<div class="post-metadata">

### Author: ![SoraK](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sorak/32/10692_2.png) [@SoraK](https://forum.getkirby.com/u/SoraK)
#### Post date: [July 28, 2021, 12:43pm UTC](https://forum.getkirby.com/t/panel-custom-css-bug/23011/7 "2021-07-28T12:43:29Z")

</div>

yes, that’s a debug output after laoding this file… if i change the key css into js, then i see a new script tag in the source tag… but css not work ☹ unless i add the code from my first post in the panel.php

---

<div class="post-metadata">

### Author: ![pixelijn](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@pixelijn](https://forum.getkirby.com/u/pixelijn)
#### Post date: [July 28, 2021, 12:52pm UTC](https://forum.getkirby.com/t/panel-custom-css-bug/23011/8 "2021-07-28T12:52:34Z")

</div>

This is the code that loads custom css

```auto
 <?php if ($customCss) : ?>
  <link nonce="<?= $nonce ?>" rel="stylesheet" href="<?= $customCss ?>">
  <?php endif ?>

```

---

<div class="post-metadata">

### Author: ![SoraK](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sorak/32/10692_2.png) [@SoraK](https://forum.getkirby.com/u/SoraK)
#### Post date: [July 28, 2021, 12:57pm UTC](https://forum.getkirby.com/t/panel-custom-css-bug/23011/9 "2021-07-28T12:57:55Z")

</div>

yeah but it seems that this code don’t work for panel css…  
the variable $customCss is filled by methods behinde the function css(‘path/to/css’)

---

<div class="post-metadata">

### Author: ![SoraK](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sorak/32/10692_2.png) [@SoraK](https://forum.getkirby.com/u/SoraK)
#### Post date: [July 28, 2021, 1:12pm UTC](https://forum.getkirby.com/t/panel-custom-css-bug/23011/10 "2021-07-28T13:12:16Z")

</div>

Only the class method addCustomCss() fills the variable $customCss but no script call this function… So the $customCss is always empty 🤷‍♂️

EDIT:  
Found one line that calls the addCustomCss function:

File: AppErrors.php  
Line 75

$handler-\>addCustomCss(‘whoops.css’);

---

<div class="post-metadata">

### Author: ![SoraK](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sorak/32/10692_2.png) [@SoraK](https://forum.getkirby.com/u/SoraK)
#### Post date: [July 28, 2021, 1:24pm UTC](https://forum.getkirby.com/t/panel-custom-css-bug/23011/11 "2021-07-28T13:24:30Z")

</div>

FIXED the problem…

i run kirby in multisite mode…  
kirby checks if the file exists before inlcude the file…  
in multisite mode the “global” asset folder is located in the root dir.  
i create a new asset folder under the root path and now… i works…
