Use TextEntry in page title

Hello,
I would like to render a status badge next to the title in my ViewRecord page's heading. I'm trying to reuse my existing TextEntry configuration to maintain consistency, but I'm not sure how to convert it to HTML.
Here's what I've tried:

public function getHeading(): string | Htmlable
{
    $badge = TextEntry::make('status')
            ->badge()
            ->color(fn($state): string => $state->getColor())
            ->formatStateUsing(fn($state): string => $state->getLabel())
            ->toHtmlString();
            
    return new HtmlString($this->record->title . ' ' . $badge);
}


But It trigger :
Typed property Filament\Schemas\Components\Component::$container must not be accessed before initialization

Do you know if there is a way to do that? Should I instead manually create the badge in html/tailwind?

Thanks!
Was this page helpful?