Installation
composer require filafly/theme-core
Publish the package assets and config:
php artisan vendor:publish --provider="Filafly\ThemeCore\ThemeCoreServiceProvider" --tag="theme-core-config"
php artisan vendor:publish --provider="Filafly\ThemeCore\ThemeCoreServiceProvider" --tag="theme-core-assets"
Basic Configuration
Update config/theme-core.php to define your theme name, assets paths, and Filament integration settings:
'theme' => [
'name' => 'MyCustomTheme',
'assets' => [
'path' => resource_path('views/vendor/filafly-theme-core'),
],
],
First Use Case: Extending a Theme
Create a custom theme class by extending Filafly\ThemeCore\Contracts\Theme:
namespace App\Themes;
use Filafly\ThemeCore\Contracts\Theme;
class MyTheme implements Theme
{
public function getName(): string
{
return 'MyCustomTheme';
}
public function getAssets(): array
{
return [
'css' => ['css/app.css'],
'js' => ['js/app.js'],
];
}
}
Register the Theme
Bind your theme in AppServiceProvider:
public function register()
{
$this->app->bind(
\Filafly\ThemeCore\Contracts\Theme::class,
\App\Themes\MyTheme::class
);
}
Apply the Theme to Filament
In your filament.php config:
'themes' => [
'default' => env('FILAMENT_THEME', 'my-custom-theme'),
],
resources/views/vendor/filafly-theme-core/ (or custom path in config).@themeStyles, @themeScripts) to inject assets conditionally:
@themeStyles
<link href="{{ asset('css/custom.css') }}" rel="stylesheet">
@endthemeStyles
resources/views/vendor/filament/.
php artisan vendor:publish --tag="filament-views"
theme-core's partials system to replace sections (e.g., headers, footers):
// In your theme class
public function getPartials(): array
{
return [
'header' => 'filafly-theme-core::partials.header',
];
}
DarkMode trait for toggle support:
use Filafly\ThemeCore\Traits\DarkMode;
class MyTheme implements Theme
{
use DarkMode;
}
Panel class to apply theme settings:
use Filafly\ThemeCore\Filament\ThemePanel;
class CustomPanel extends ThemePanel
{
protected static string $theme = 'my-custom-theme';
}
php artisan vendor:publish --tag="filament-widget-views"
Resource classes:
use Filafly\ThemeCore\Traits\ResourceStyling;
class PostResource extends Resource
{
use ResourceStyling;
protected static string $themeResource = 'posts';
}
// In your theme class
public function getAssetsForLocale(string $locale): array
{
return [
'css' => ["css/{$locale}.css"],
];
}
'rtl' => [
'enabled' => true,
'assets' => [
'css' => ['css/rtl.css'],
],
],
public function handle(Request $request, Closure $next)
{
$theme = auth()->user()->preferred_theme ?? config('theme-core.default');
app()->bind(\Filafly\ThemeCore\Contracts\Theme::class, "App\Themes\\{$theme}Theme");
return $next($request);
}
filafly/theme-core’s v5 config flag to enable v5-specific features (e.g., spa_mode).// vite.config.js
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
input: [
'resources/js/filafly-theme-core/app.js',
'resources/sass/filafly-theme-core/app.scss',
],
refresh: true,
}),
],
});
public_path() in config/theme-core.php points to /public.tailwind.config.js to include theme-specific colors:
module.exports = {
theme: {
extend: {
colors: {
primary: {
500: '#3b82f6', // Override with your theme's palette
},
},
},
},
};
:root {
--primary-500: theme('colors.primary.500');
}
Asset Loading Order
@stack directives to control load order:
@stack('meta.styles.pre')
@themeStyles
@stack('meta.styles')
Caching Conflicts
php artisan cache:clear
php artisan view:clear
php artisan filament:cache-reset
Namespace Collisions
composer.json:
"autoload": {
"psr-4": {
"App\\Themes\\": "app/Themes/"
}
}
Dark Mode Toggle
// In your theme class
public function toggleDarkMode(): void
{
$preference = request()->cookie('dark_mode') === 'true';
session()->put('dark_mode', $preference);
response()->cookie('dark_mode', $preference ? 'true' : 'false', 60 * 24 * 30);
}
Partial Overrides
@extends('filament::partials.header')
@section('header.extra')
<div class="custom-header-content"></div>
@endsection
Asset Paths
config/theme-core.php and resources/views/vendor/filafly-theme-core/.{{ asset('') }} in Blade to debug paths.Theme Binding
dd(app(\Filafly\ThemeCore\Contracts\Theme::
How can I help you explore Laravel packages today?