FilamentF
Filament14mo ago
Xiaohou

Filament color is not reactive

At first, i found out the badge color inside table doesn't update alone with the text.
For example, when the status value is changed from activated to deactivated, the text inside badge will update to the getLabel() value, however, the color of the badge stay the same. I thought it was an issue relating to badge.

The text column code:
Tables\Columns\TextColumn::make('status'),


The enum status code:
<?php

namespace App\Enums;

use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasLabel;

enum UserStatus: string implements HasLabel, HasColor
{
    case Activated = 'activated';
    case Deactivated = 'deactivated';

    public function getLabel(): ?string
    {
        return match ($this) {
            self::Activated => 'activated',
            self::Deactivated => 'deactivated',
        };
    }

    public function getColor(): array|string
    {
        return match ($this) {
            self::Activated => 'success',
            self::Deactivated => 'danger',
        };
    }
}


Upon some more troubleshooting, i realized all colors are not reactive.

Even when i have a method that dynamically return filament action, lets say ban or unban action, which has danger or success color. The dynamic action will update based on user status, however, the color of the action itself doesnt change.
Was this page helpful?