Is there a simple way to change the color of a Placeholder field in a form?

I have a dynamically populated Placeholder field that pulls data from the database based on the value of another field, but I want to change the text color and/or background color to a lighter gray color to differentiate it from the other editable fields.
Solution:
Placeholder::make()->extraAttributes([‘class’ => ‘text-gray-400’])
Jump to solution
8 Replies
pechtelt
pechtelt2y ago
For example:
->content(fn(?Modal $record) => new HtmlString('<span class="text-gray-400 font-sm">' . $record->data . '</span>'))
->content(fn(?Modal $record) => new HtmlString('<span class="text-gray-400 font-sm">' . $record->data . '</span>'))
richeklein
richekleinOP2y ago
Thanks. One complication is that my content is already dynamically generated via a ->content(function (Get $get) : string { .....
Solution
awcodes
awcodes2y ago
Placeholder::make()->extraAttributes([‘class’ => ‘text-gray-400’])
richeklein
richekleinOP2y ago
Yes! extraAttributes was what I was looking for! Thanks so much. I was looking around the docs, not sure how I missed it (https://filamentphp.com/docs/3.x/forms/fields/getting-started#adding-extra-html-attributes). Once I finish my first admin panel, I'm going to work on another round of documentation PR's. I have a lot of notes on where I'm getting stuck, being new to Filament. 😄
pechtelt
pechtelt2y ago
Thanks im learning also this way! Sorry for the ‘wrong’ answer…
awcodes
awcodes2y ago
If it works, doesn’t mean it’s wrong. Sometimes, there’s just more appropriate options. Cheers.
richeklein
richekleinOP2y ago
Thanks for your help. I'm also learning and your response was helpful and I'm sure it will be useful in the future. I documented it as well. 👍

Did you find this page helpful?