Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Livewire

Building Data Tables with Livewire v4

Create sortable, filterable data tables.

1 February 20261 min readLivewireاقرأ بالعربية

On this page

  1. Component

Build powerful data tables.

Component

php
@php
use Livewire\WithPagination;
use Livewire\Attributes\Url;

new class extends Livewire\Component {
    use WithPagination;
    
    #[Url]
    public string $search = '';
    
    #[Url]
    public string $sortBy = 'created_at';
    
    #[Url]
    public string $sortDir = 'desc';
    
    public function sort(string $column): void
    {
        $this->sortDir = $this->sortBy === $column && $this->sortDir === 'asc' ? 'desc' : 'asc';
        $this->sortBy = $column;
    }
}
@endphp
All articles

Keep reading

  • Authorization in Livewire v4 Components1 February 20261 min read
  • Blaze Pre-Compiler: Massive Performance Gains in Livewire v41 February 20261 min read
  • Building a Bookmark Feature with Livewire v41 February 20261 min read