Download the PHP package uccellolabs/filament-theme-color without Composer
On this page you can find all versions of the php package uccellolabs/filament-theme-color. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download uccellolabs/filament-theme-color
More information about uccellolabs/filament-theme-color
Files in uccellolabs/filament-theme-color
Package filament-theme-color
Short Description Easy way to change filament theme color on the fly.
License MIT
Informations about the package filament-theme-color
Filament Theme Color
Easy way to change filament theme color on the fly.
In some projects, it is interesting to be able to change the main colors of a theme.
For example, if you manage several tenants, you may want to assign different colors to each tenant. Or maybe depending on the user's role, you want a different theme color.
This library allows to assign a primary and a secondary color to the theme.
Installation
You can install the package via composer:
Configuration
Since Filament's styles are compiled in a CSS file, it is not easy to modify the colors of the theme.
So we will create a palette made of CSS variables instead of colors.
Then, we will just have to update the CSS variables so that the colors change automatically.
Create a custom theme
We will start by following the instructions to create a custom theme for Filament.
You can do it by following the instructions here: https://filamentphp.com/docs/2.x/admin/appearance#building-themes
Configure theme colors
Modify the tailwind.config.js
file as follows to use CSS variables instead of colors:
Then run the npm run dev
command to compile the new theme.
The package uses the palettey library which allows to generate a palette from a simple color.
Usage
It is now possible to easily change the colors of the theme.
To do so, modify the app/Providers/AppServiceProvider.php
file as follows:
You can now use all the primary and secondary colors of the generated palettes:
If you want to do a live preview, it is possible to change the color with a custom event.
It is also possible to do it from Livewire :
Credits
License
The MIT License (MIT). Please see License File for more information.