laravel-theme-switcher maintained by protik
Description
A Laravel package to switch website themes (light/dark mode)
Author
Last update
2025/12/20 10:47
(dev-master)
License
Downloads
2
Laravel Theme Switcher
A simple, plug-and-play Laravel package for switching between multiple themes with zero configuration required.
Installation
composer require protik/laravel-theme-switcher
Quick Setup
Step 1: Add Middleware
In bootstrap/app.php, add the middleware to the web group:
->withMiddleware(function (Middleware $middleware): void {
$middleware->web(append: [
\Protik\ThemeSwitcher\Middleware\ApplyTheme::class,
]);
})
Step 2: Use in Your Views
Add the theme class to your <body> tag and include the toggle component:
<body class="{{ $theme }}">
<x-theme-switcher-toggle />
<!-- Your content -->
</body>
That's it! The package automatically injects default styles and provides theme switching functionality.
Features
- ✅ Multiple themes support (light, dark, blue, etc.)
- ✅ Zero configuration required
- ✅ Auto-injected CSS styles
- ✅ Session-based theme storage
- ✅ Blade component for easy integration
- ✅ Fully customizable via config
Customization (Optional)
Publish the config file to customize themes:
php artisan vendor:publish --tag=config --provider="Protik\ThemeSwitcher\ThemeSwitcherServiceProvider"
Edit config/theme-switcher.php to:
- Add/modify themes
- Change default theme
- Disable default styles
Requirements
- PHP ^8.1
- Laravel ^12.0
License
MIT