How to Passing value for color in extraAttributes to them.css?
I want to Passing value for color in extraAttributes to them.css .cuze the color from database
11 Replies
The best way to output colors from the database is via inline styles
you could add “style” as an extraattribute
ok ,but I have class inside class ,so I want to change color for internal class
use the style attribute to define a css variable and use the css variable inside the internal class
I want to change Select not cell my cod is
->extraAttributes(fn($record) => [
'style' =>"background-color:red"
])
I want do like this image
define the css variable in the style attribute, then add a class to your theme css that targets the select box and applies the bg color from the css variable
where define the css variable?plase
->extraAttributes(fn($record) => [
'class' => match ($record->compliance_status) {
'Compliant' => 'class-Compliant',
'Not Applicable' => 'class-Not-Applicable',
'Not Compliant' => 'class-Not-Compliant',
'Partially Compliant' => 'class-Partially-Compliant',
default => 'class-default', // Handle other cases if necessary
},
'style' => "color: " . $record->color . ";", // Add this line to set the color
])
See if you can figure it out from here https://ishadeed.com/article/css-variables-inline-styles#button-color
i dont have time to write out code for every single question, you should have a go yourself and post the solution for others
ok,brother
thanks alot brother ,I fixed after you help me thanks