© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•4mo ago•
3 replies
Tom | Netbela

How to properly use the listWithLineBreaks method from TextColumn

Heya guys, i've been playing around with the
TextColumn
TextColumn
listWithLineBreaks
listWithLineBreaks
function paired with some JSON data. I store this data in the database:
[{"type":"LAPTOP","data":{"Merk":"Bakkers Studio Stichting","Model":"et064","CPU":"Intel i5","RAM":"16GB","Opslag":"1TB HDD"}}]
[{"type":"LAPTOP","data":{"Merk":"Bakkers Studio Stichting","Model":"et064","CPU":"Intel i5","RAM":"16GB","Opslag":"1TB HDD"}}]


which is being casted to an array from the model
    protected function casts(): array
    {
        return [
            'specs' => 'array',
        ];
    }
    protected function casts(): array
    {
        return [
            'specs' => 'array',
        ];
    }


Now I would like to have all the data from
data
data
to be displayed in a table using the listWithLineBreaks function. I assumed that this would need an array to work with. So, my assumption would be that:
                TextColumn::make('specs')
                    ->label('specs')
                    ->searchable()
                    ->listWithLineBreaks()
                    ->formatStateUsing(function ($state) {
                        if (empty($state['data'])) {
                            return '-';
                        }
                        
                        return $state['data'];
                    })
                TextColumn::make('specs')
                    ->label('specs')
                    ->searchable()
                    ->listWithLineBreaks()
                    ->formatStateUsing(function ($state) {
                        if (empty($state['data'])) {
                            return '-';
                        }
                        
                        return $state['data'];
                    })

Would properly display the items in a list format. but It does not.

So, i've tried supplying the 'listWithLineBreaks' not with an array, but with a string by
implode
implode
:
                TextColumn::make('specs')
                    ->label('specs')
                    ->searchable()
                    ->listWithLineBreaks()
                    ->separator(';')
                    ->formatStateUsing(function ($state) {
                        if (empty($state['data'])) {
                            return '-';
                        }

                        return implode(';', $state['data']);
                    }),
                TextColumn::make('specs')
                    ->label('specs')
                    ->searchable()
                    ->listWithLineBreaks()
                    ->separator(';')
                    ->formatStateUsing(function ($state) {
                        if (empty($state['data'])) {
                            return '-';
                        }

                        return implode(';', $state['data']);
                    }),

But that also results in a single string being displayed and not being separated on the ';'.

A workaround is to use the
html()
html()
function and add
<br/>
<br/>
to the output string but i'd rather use the function above. What am I missing out here?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

How to Enum on TextColumn method?
FilamentFFilament / ❓┊help
3y ago
How to use TextColumn instead of SelectColumn?
FilamentFFilament / ❓┊help
3y ago
Numeric TextColumn: sortable() not working properly
FilamentFFilament / ❓┊help
2y ago