© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•5mo ago•
1 reply
JungleOnly

Changing <x-filament:button> color on click of the button

Hi folks,

I'm trying to build a tabbed Blade-View of some of my livewire components.

<x-filament::page>
    <div x-data="{ tab: 'new-employees' }">

        <div class="flex space-x-2 mb-4">
            <x-filament::button color="gray" class="text-white px-4 py-1 rounded"
                x-bind:class="tab === 'new-employees' ? 'bg-green-600' : 'bg-gray-400'" 
                @click="tab = 'new-employees'">
                Neue Mitarbeiter
            </x-filament::button>

            <x-filament::button color="gray" class="text-white px-4 py-1 rounded"
                x-bind:class="tab === 'facility-changes' ? 'bg-green-600' : 'bg-gray-400'"
                @click="tab = 'facility-changes'">
                Einrichtungswechsel
            </x-filament::button>

            <x-filament::button color="gray" class="text-white px-4 py-1 rounded"
                x-bind:class="tab === 'employment-changes' ? 'bg-green-600' : 'bg-gray-400'"
                @click="tab = 'employment-changes'">
                Anstellungstypwechsel
            </x-filament::button>

        </div>

        <div>
            <br>
        </div>

        <div>
            <div x-show="tab === 'new-employees'"> @livewire('new-employee-table') </div>
            <div x-show="tab === 'facility-changes'"> @livewire('facility-change-table') </div>
            <div x-show="tab === 'employment-changes'"> @livewire('employment-change-table') </div>
        </div>

    </div>
</x-filament::page>
<x-filament::page>
    <div x-data="{ tab: 'new-employees' }">

        <div class="flex space-x-2 mb-4">
            <x-filament::button color="gray" class="text-white px-4 py-1 rounded"
                x-bind:class="tab === 'new-employees' ? 'bg-green-600' : 'bg-gray-400'" 
                @click="tab = 'new-employees'">
                Neue Mitarbeiter
            </x-filament::button>

            <x-filament::button color="gray" class="text-white px-4 py-1 rounded"
                x-bind:class="tab === 'facility-changes' ? 'bg-green-600' : 'bg-gray-400'"
                @click="tab = 'facility-changes'">
                Einrichtungswechsel
            </x-filament::button>

            <x-filament::button color="gray" class="text-white px-4 py-1 rounded"
                x-bind:class="tab === 'employment-changes' ? 'bg-green-600' : 'bg-gray-400'"
                @click="tab = 'employment-changes'">
                Anstellungstypwechsel
            </x-filament::button>

        </div>

        <div>
            <br>
        </div>

        <div>
            <div x-show="tab === 'new-employees'"> @livewire('new-employee-table') </div>
            <div x-show="tab === 'facility-changes'"> @livewire('facility-change-table') </div>
            <div x-show="tab === 'employment-changes'"> @livewire('employment-change-table') </div>
        </div>

    </div>
</x-filament::page>


This code is currently working flawlessly in terms of switching around the tabs by clicking on the corresponding buttons.

What's not working is switching up the button's color in the @click action.

Can someone provide help that previously solved this problem?

Thank you for any input!
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

conditionally disable <x-filament::icon-button>
FilamentFFilament / ❓┊help
3y ago
Infolist section header actions x-on:click.stop="x-on:click.stop"
FilamentFFilament / ❓┊help
3y ago
using @js in <x-filament::button wire:click="doMethod(@js($data))"> will fail
FilamentFFilament / ❓┊help
3y ago
Load records on button click
FilamentFFilament / ❓┊help
2y ago