PHP code example of r0073rr0r / laravel-theme-switcher

1. Go to this page and download the library: Download r0073rr0r/laravel-theme-switcher library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

r0073rr0r / laravel-theme-switcher example snippets


return [
    'default_preference' => 'system',
    'allowed_preferences' => ['light', 'dark', 'system'],
    'cycle_order' => ['light', 'dark', 'system'],
    'animations' => [
        'enabled' => true,
        'duration' => 300,
        'icon_transition' => true,
        'hover_effects' => true,
        'respect_reduced_motion' => true,
    ],
    'persistence' => [
        'cookie_enabled' => true,
        'cookie_name_preference' => 'theme_preference',
        'cookie_name_theme' => 'theme',
        'cookie_minutes' => 60 * 24 * 365,
        'database_enabled' => true,
    ],
    'ui' => [
        'show_system_option' => true,
        'button_size' => 'md',
        'rounded' => 'full',
        'show_tooltip' => true,
    ],
    'events' => [
        'dispatch_theme_changed' => true,
        'dispatch_preference_updated' => true,
    ],
];

__('theme-switcher::theme-switcher.appearance')
__('theme-switcher::theme-switcher.save')
bash
php artisan vendor:publish --tag=theme-switcher
bash
php artisan vendor:publish --tag=theme-switcher-views
bash
php artisan vendor:publish --tag=theme-switcher-translations
bash
php artisan vendor:publish --tag=theme-switcher-css
bash
php artisan vendor:publish --tag=theme-switcher-assets
bash
php artisan migrate
bash
composer update r0073rr0r/laravel-theme-switcher
php artisan vendor:publish --tag=theme-switcher-views --force
php artisan vendor:publish --tag=theme-switcher-translations --force
php artisan vendor:publish --tag=theme-switcher-css --force
php artisan vendor:publish --tag=theme-switcher-assets --force
css
@source "../../vendor/r0073rr0r/laravel-theme-switcher/resources/views/**/*.blade.php";
css
@source "../views/vendor/theme-switcher/**/*.blade.php";
text
resources/views/profile/show.blade.php
text
resources/views/profile/update-appearance-form.blade.php
bash
php vendor/bin/pest