Is it possible to autoload a panel CSS from a plugin?

I have a plugin where I’d like to add a couple of CSS styles to change some of the appearance of specific fields in the Panel. I’m not using any custom fields, just the built-in Kirby fields - but these fields now have classes that allow us to target them specifically via field name. So, I’d like to add a panel CSS file to my plugin, that would automatically load the style changes I need in those specific fields.

Is that possible?

No, these assets are not autoloaded, but you can include such a file in your config:

'panel' => [
    'css' => 'media/plugins/me/myplugin/css/custom.css'

An index.css in your plugin main folder will be auto loaded into the panel. Same goes for index.php and index.js. No need to define them specifically.


Ah, I thought that was only true for Panel plugins. Thanks, good to know.

@moeli how did you ever find that out? :smile:

It is not very clear in the docs, but the basic js plugin structure as explained for panel views is a good starting point for experiments :wink:

Technically you are right. You still need a plugins index.php to trigger the auto loading.

1 Like