How to change the colors of the columns of the table builder widget ?

I would like to change the colors so that instead of putting a filter, I would like to change the color of the column
15 Replies
Dennis Koch
Dennis Koch2y ago
Try extraAttributes(['class' => 'bg-gray-100']. Make sure you have a custom Tailwind CSS build or use classes that are in Filaments JIT version
Becker Maxime
Becker MaximeOP2y ago
or should I add this function, I am in a resource ?
Dennis Koch
Dennis Koch2y ago
On the column, if that's where you want to change the color.
Becker Maxime
Becker MaximeOP2y ago
what is the function to get some columns from our tableBuilder in a resource ?
Dennis Koch
Dennis Koch2y ago
What do you mean by "Get a column from the table builder"? You define columns of the table, so that's where it goes
Becker Maxime
Becker MaximeOP2y ago
excuse me I meant a row in my table, I would like to change the color of my row ?
Becker Maxime
Becker MaximeOP2y ago
protected function getTableRecordClassesUsing(): ?Closure
{
return fn(Trainee $record) => match ($record->archive) {
'0' => [
'border-l-2 border-orange-600',
'dark:border-orange-300' => config('tables.dark_mode'),
],
'1' => 'border-l-2 border-green-600',
default => null,
};
}
protected function getTableRecordClassesUsing(): ?Closure
{
return fn(Trainee $record) => match ($record->archive) {
'0' => [
'border-l-2 border-orange-600',
'dark:border-orange-300' => config('tables.dark_mode'),
],
'1' => 'border-l-2 border-green-600',
default => null,
};
}
I added this function in my resource but I notice no change
toeknee
toeknee2y ago
You will need to add it to the list page not the primary resource
Becker Maxime
Becker MaximeOP2y ago
protected function getTableRecordClassesUsing(): ?Closure
{
return fn(Trainee $trainee) => match ($trainee->name) {
'TOTO' => [
'border-l-2 border-orange-600',
'dark:border-orange-300' => config('tables.dark_mode'),
],
};
}
protected function getTableRecordClassesUsing(): ?Closure
{
return fn(Trainee $trainee) => match ($trainee->name) {
'TOTO' => [
'border-l-2 border-orange-600',
'dark:border-orange-300' => config('tables.dark_mode'),
],
};
}
even when adding it to my page I have no color change
toeknee
toeknee2y ago
Are the classes applied in the html? And are you using the table within admin panel, or table outside admin?
Becker Maxime
Becker MaximeOP2y ago
protected function getTableRecordClassesUsing(): ?Closure
{
return function (Trainee $trainee) {
match ($trainee->archive) {
1 => 'dark:bg-gray-150',
0 => 'bg-gray-800',
};
};
}
protected function getTableRecordClassesUsing(): ?Closure
{
return function (Trainee $trainee) {
match ($trainee->archive) {
1 => 'dark:bg-gray-150',
0 => 'bg-gray-800',
};
};
}
None of my classes are called in my console. I am in the ListRecords of my resource.
Dennis Koch
Dennis Koch2y ago
You don't return anything from the Closure
Becker Maxime
Becker MaximeOP2y ago
thanks
Want results from more Discord servers?
Add your server