Theme Selector

It's like having a magic wand for your website's vibe. With the Theme Selector, users can switch between a cool dark theme or a bright light theme, depending on their mood or preference. It's like having the power to change the ambiance of your digital space with just a click!

Configuration

Before start using the theme selectors you would need to include this script to be able to switch the theme globally

<script>
    // On page load or when changing themes, best to add inline in `head` to avoid FOUC
    if (
        localStorage.theme === 'dark' ||
        (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)
    ) {
        document.documentElement.classList.add('dark');
    } else {
        document.documentElement.classList.remove('dark');
    }
</script>

Theme Toggle

Adding the component

php artisan spur:add interactives/theme-toggle forms/toggle

If you use this to add the component, it will automatically add it to config/spur.php and auto-fetch the components files.

config/spur.php
"components": [
  'interactives/theme-toggle',
  'forms/toggle',
]

If you manually add the component in config/spur.php you would need to run
php artisan spur:fetch to import the component

<x-spur.theme-toggle />

Theme Button

Adding the component

php artisan spur:add interactives/theme-button essentials/button

If you use this to add the component, it will automatically add it to config/spur.php and auto-fetch the components files.

config/spur.php
"components": [
  'interactives/theme-button',
  'essentials/button',
]

If you manually add the component in config/spur.php you would need to run
php artisan spur:fetch to import the component

<x-spur.theme-button lightClasses="text-brand-yellow" darkClasses="text-indigo-400" />

Theme Selector

Adding the component

php artisan spur:add interactives/theme-selector interactives/dropdown interactives/dropdown-option essentials/button

If you use this to add the component, it will automatically add it to config/spur.php and auto-fetch the components files.

config/spur.php
"components": [
  'interactives/theme-selector',
  'interactives/dropdown',
  'interactives/dropdown-option',
  'essentials/button',
]

If you manually add the component in config/spur.php you would need to run
php artisan spur:fetch to import the component

Light Dark System
<x-spur.theme-button lightClasses="text-brand-yellow" darkClasses="text-indigo-400" />