nrep/filament-theme-switcher
Composer 安装命令:
composer require nrep/filament-theme-switcher
包简介
A FilamentPHP plugin that allows users to easily switch and customize application themes
README 文档
README
A FilamentPHP plugin that allows users to easily switch and customize application themes. Supports both global themes and per-user theme preferences.
Features
- 🎨 7 Pre-built Themes: Default, Sunset, Ocean, Forest, Midnight, Rose, and Amber
- 🔄 Easy Theme Switching: Quick switch via dropdown or dedicated settings page
- 🎯 Per-User Themes: Optional per-user theme preferences with database storage
- 🖌️ Custom Colors: Override any theme color with custom color picker
- 🔐 Authorization: Control who can access theme settings
- 🌍 Translatable: Full translation support
- ⚡ Filament v3 & v4 Compatible: Works with both major versions
Requirements
- PHP 8.1+
- Laravel 10.x, 11.x, or 12.x
- Filament 3.x or 4.x
Installation
Install the package via composer:
composer require nrep/filament-theme-switcher
Publish the config file (optional):
php artisan vendor:publish --tag="filament-theme-switcher-config"
For per-user theme support, publish and run the migrations:
php artisan vendor:publish --tag="filament-theme-switcher-migrations"
php artisan migrate
Usage
Basic Setup
Register the plugin in your Panel provider:
use Isura\FilamentThemeSwitcher\FilamentThemeSwitcherPlugin; public function panel(Panel $panel): Panel { return $panel // ... other configuration ->plugin( FilamentThemeSwitcherPlugin::make() ); }
Add the middleware to apply themes:
use Isura\FilamentThemeSwitcher\Http\Middleware\SetTheme; public function panel(Panel $panel): Panel { return $panel // ... other configuration ->middleware([ // ... other middleware SetTheme::class, ]); }
Configuration Options
Theme Mode
Set the theme mode in the config file or via the plugin:
// config/filament-theme-switcher.php return [ 'mode' => 'global', // or 'user' for per-user themes 'default_theme' => 'default', ];
Plugin Configuration
FilamentThemeSwitcherPlugin::make() // Set the theme mode ->mode('user') // 'global' or 'user' // Customize navigation ->navigationGroup('Settings') ->navigationIcon('heroicon-o-paint-brush') ->navigationSort(100) ->navigationLabel('Appearance') // Control page access ->registerNavigation(true) // Show/hide from navigation ->canViewThemesPage(fn () => auth()->user()?->is_admin) // Register custom themes ->registerThemes([ 'my-theme' => MyCustomTheme::class, ]) // Override default themes entirely ->registerThemes([ 'my-theme' => MyCustomTheme::class, ], override: true);
Creating Custom Themes
Create a new theme by extending AbstractTheme:
<?php namespace App\Filament\Themes; use Filament\Support\Colors\Color; use Isura\FilamentThemeSwitcher\Themes\AbstractTheme; class MyCustomTheme extends AbstractTheme { public static function getName(): string { return 'my-custom-theme'; } public function getLabel(): string { return 'My Custom Theme'; } public function getColors(): array { return [ 'primary' => Color::Purple, 'danger' => Color::Red, 'gray' => Color::Slate, 'info' => Color::Blue, 'success' => Color::Green, 'warning' => Color::Amber, ]; } }
Register your custom theme:
FilamentThemeSwitcherPlugin::make() ->registerThemes([ 'my-custom-theme' => MyCustomTheme::class, ]);
Using Hex Colors
You can use hex colors instead of Filament's Color constants:
public function getColors(): array { return [ 'primary' => '#8b5cf6', 'danger' => '#ef4444', 'gray' => '#64748b', 'info' => '#3b82f6', 'success' => '#22c55e', 'warning' => '#f59e0b', ]; }
Theme Switcher Component
Add the theme switcher dropdown to your panel's render hooks:
use Filament\View\PanelsRenderHook; use Illuminate\Support\Facades\Blade; public function panel(Panel $panel): Panel { return $panel ->renderHook( PanelsRenderHook::USER_MENU_BEFORE, fn () => Blade::render('@livewire(\'theme-switcher\')') ); }
Available Themes
| Theme | Primary Color | Description |
|---|---|---|
| Default | Blue | Clean, professional blue theme |
| Sunset | Orange | Warm orange and amber tones |
| Ocean | Cyan | Cool ocean-inspired colors |
| Forest | Emerald | Natural green forest theme |
| Midnight | Indigo | Deep purple night theme |
| Rose | Rose | Soft pink and rose colors |
| Amber | Amber | Warm golden tones |
Authorization
Control who can access the theme settings page:
FilamentThemeSwitcherPlugin::make() ->canViewThemesPage(fn () => auth()->user()?->hasPermission('manage-themes'));
Translations
Publish the language files:
php artisan vendor:publish --tag="filament-theme-switcher-translations"
The package includes English translations. Add your own translations in resources/lang/vendor/filament-theme-switcher/.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
nrep/filament-theme-switcher 适用场景与选型建议
nrep/filament-theme-switcher 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 110 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「theme」 「laravel」 「filament」 「filament-plugin」 「nrep」 「theme-switcher」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nrep/filament-theme-switcher 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nrep/filament-theme-switcher 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nrep/filament-theme-switcher 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Bootstrap 4.x base theme for SilverStripe
Lucency Theme
Selectize Theme for Bootstrap 4
Alfabank REST API integration
Ratchakarn theme for Yii Framework 2
AdminLTE backend theme asset bundle for Yii 2.0 Framework with Bootstrap 4
统计信息
- 总下载量: 110
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-11