© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
exactwebitesolutions

Default sort direction for a column - descending first

To improve the UX I wanted to change how the ‘Updated at’ timestamp are sorted descending on first click of a column.

I know you can change the default order for the whole table but here I'm referring to the individual column sorting - when you click on a column.

On first click of a timestamp column you most likely want to see the recent first, and not oldest.

If I reverse the direction in the query it kinda works but the label/arrow are incorrect.
Tables\Columns\TextColumn::make('updated_at')
        ->sortable(query: fn (Builder $query, string $direction): Builder =>
            $query->orderBy('updated_at', $direction === 'asc' ? 'desc' : 'asc'))
Tables\Columns\TextColumn::make('updated_at')
        ->sortable(query: fn (Builder $query, string $direction): Builder =>
            $query->orderBy('updated_at', $direction === 'asc' ? 'desc' : 'asc'))
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Change column sort direction to descending by default
FilamentFFilament / ❓┊help
3y ago
Default sort direction on table groups
FilamentFFilament / ❓┊help
2y ago
Change Default Order To Descending
FilamentFFilament / ❓┊help
3y ago
Default sort direction based on defaultgroup in table builder
FilamentFFilament / ❓┊help
3y ago