F
Filament4mo ago
H4L1M

Form Component Placeholder

hello, can placeholder's text colors be changed ? red and bold for example
Placeholder::make('User Status')
->content('Banned at : 02-17-2024 14:50 By Admin')
Placeholder::make('User Status')
->content('Banned at : 02-17-2024 14:50 By Admin')
Solution:
Yes you can inject html code inside of content() and just use inline css
Jump to solution
2 Replies
Solution
Prosp30
Prosp304mo ago
Yes you can inject html code inside of content() and just use inline css
H4L1M
H4L1M4mo ago
hello, the place holder accepts a method ->extraAttributes() the solution is to pass css class in an array like this
Forms\Components\Placeholder::make('User.ban')
->extraAttributes([
'class' => 'text-danger-600',
])
->content('red text')
Forms\Components\Placeholder::make('User.ban')
->extraAttributes([
'class' => 'text-danger-600',
])
->content('red text')
how ever theres only text-danger-600 compiled in the CSS app class , so am using
'sytle' => 'color: red'
'sytle' => 'color: red'
instead , did I forget somethig ? also the palceholder accepts HTML code ingection like this
->content(function ($record) {
$content = $record->isBanned()
? '<p style="color: red" class="font-bold">Banned</p>
<span class="block sm:inline">This user is Banned.</span>'
: '<p style="color: green" class="font-bold">Not Banned</p>
<span class="block sm:inline">This user currently has no active bans.</span>';
return new HtmlString($content);
})
->content(function ($record) {
$content = $record->isBanned()
? '<p style="color: red" class="font-bold">Banned</p>
<span class="block sm:inline">This user is Banned.</span>'
: '<p style="color: green" class="font-bold">Not Banned</p>
<span class="block sm:inline">This user currently has no active bans.</span>';
return new HtmlString($content);
})
as @Prosp30 motioned , thnks