Pekka
Pekka

Reputation: 449505

How to build and package themes for Laravel Backpack?

I'm developing two Laravel+Backpack applications at the same time.

I'm styling and changing the look and feel of Backpack a lot, not just on the CSS level, but also inside individual Blade templates.

Most of the changes apply to both applications I'm working on.

Currently, I will apply changes I make to one application manually to the other by copy+pasting the files and changes in /resources/views/vendor/backpack/crud and some custom CSS.

That however gets old fast, and I'm starting to think I should be building a package that I can share between projects. Maybe the changes I make eventuelly turn into a theme that might interest others and I'd need a delivery mechanism for that as well.

Does anyone have some pointers how to best do this. I'm new to the Laravel ecosystem and seeing a lot of advice on how to create a Laravel package, but I'm not sure if that applies to my situation.

What I'm looking for is to create a package that does nothing more than mirror the original views and CSS resources in vendor/backpack/crud/src/resources, but of course can also be customized in the project itself.

So when Backpack builds the UI, it would look up, say, a view

Does Backpack even allow for that at present?

Upvotes: 4

Views: 589

Answers (1)

Pekka
Pekka

Reputation: 449505

Turns out there is some theming support in Backpack!

https://backpackforlaravel.com/docs/5.x/base-how-to#create-a-new-theme-child-theme

You can create a theme with your own HTML. Create a folder with all the views you want to overwrite, then change view_namespace inside your config/backpack/base.php to point to that folder. All views will be loaded from that folder if they exist, then from resources/views/vendor/backpack/base, then from the Base package.

You can use child themes to:

create packages for your Backpack admin panels to look different (and re-use across projects) use a different CSS framework (ex: Tailwind, Bulma)

Changes are to come in the upcoming v6 of backpack:

We are completely re-writing the theming/asset system in Backpack v6 (due next months).

Upvotes: 3

Related Questions