FilamentF
Filament15mo ago
lbar

extraAttributes add class on Section seems not works

hi! actually i have a form section like this:

Section::make()                                
    ->description('Main Contact Referent')
    ->relationship('user')
    ->schema([
        TextInput::make('firstname')
            ->label('First Name')
            ->formatStateUsing(fn($record) => $record->mainMember ? $record->mainMember->firstname : null)
            ->disabled(),
        TextInput::make('lastname')
            ->label('Last Name')
            ->formatStateUsing(fn($record) => $record->mainMember ? $record->mainMember->lastname : null)
            ->disabled(),
        TextInput::make('tax_code')
            ->label('Tax Code')
            ->disabled(),
    ])
    ->collapsed()
    ->extraAttributes(['class' => 'bg-neutral-950']),


the class added on the html appear correctly, but nothing change from the rendered html. I basically want change a background for a specific section of this form. Is that a correct approach?
ty
Solution
it was not rendered at all. actually i have solved creating a custom theme and there creating a class like
.mycustom-background {
    @apply bg-neutral-950 !important;
}

and then
->extraAttributes(['class' => 'mycustom-background']),

But to me this seems an overkill. not sure if this is the best approach to do this. So before to mark it solved, i just wait for some others opinions.
Was this page helpful?