protik/laravel-theme-switcher

A Laravel package to switch website themes (light/dark mode)

Maintainers

Package info

github.com/ProtikAcharjay/laravel-theme-switcher

pkg:composer/protik/laravel-theme-switcher

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2025-12-20 09:47 UTC

This package is auto-updated.

Last update: 2026-03-20 10:27:21 UTC


README

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