Data Tables Components

Livewire Datatable with Filter and Sort Options

Filter and Sort table results using laravel livewire

UI Stack: Tailwind CSS

Datatables with Search and Filters

You can filter the data by searching for name/price/description, also use sorting and pagination.

Title
Description
Price
Amazon Basics In-Ear 10.99
Apple Airpods 79.99
Apple Airpods Pro 249
Beats Earbuds 35.63
Beats Solo3 170.49
Bose SoundSport 99
Cowin E7 59.99
Cowin E7 59.99
Cowin E7 59.99
Noot Kids K11 14.99

Code

Sorry, this component's code is restricted
Sorry, this component's code is restricted

Overview

This guide will walk you through the steps to implement a dynamic datatable component in Laravel using Livewire. This datatable component features server-side sorting, searching, and pagination. It is built to interact with a dummy product model, but can be easily adapted to suit your needs.

Implementation

Firstly, you need to place files in their correct directories according to the default Laravel/Livewire directory structure:

  • Copy the component file to your app/Livewire directory. Rename the file to DataTableComponent.php.
  • Copy the blade view to your resources/views/livewire directory. Rename the file to datatable-component.blade.php.

Integration

Once the files are placed in their respective directories, you can use the datatable component in your Laravel project. Simply include the Livewire component in any of your Blade views using the @livewire('datatable-component') directive.

Usage

Here is a basic usage example:


// In any blade view
@livewire('datatable-component')

The datatable component will be rendered in the place of the directive. It includes a search field for each column and pagination links at the bottom. The user can click the column headers to sort the data.

Configuration & Customization

The datatable component can be customized to fit your needs. Here are some of the configuration options:

  • $orderByColumn and $order: Define the default column to sort by and the sorting order.
  • $paginate: Set the number of items to display per page.
  • $searchColumns: Define the columns that are searchable.

You can also customize the Blade view to change the appearance of the datatable or add more features, like filters or buttons.

Livewire ToDo List with in-place edit and delete

Add, edit, delete tasks feature along with ability to mark task complete.

UI Stack: Bootstrap 5

Awesome ToDo List
  • Task 1
  • Task 2
  • Task 3
  • Task 4
  • Task 5

Code
Please login to View/Download the Code

Sorry, this component's code is restricted
Sorry, this component's code is restricted

Overview

This component enables a ToDo list functionality in your Laravel application. It allows users to add, edit, and delete tasks. Each task can be marked as complete or incomplete. The tasks are displayed in the order they were created, with the most recent tasks displayed first.

Implementation

Follow these steps to implement the ToDo list component in your Laravel project:

1. Copy the ToDoList.php file to your app/Livewire directory.

2. Copy the to-do-list.blade.php file to your resources/views/livewire directory.

Integration

To integrate the ToDo list component into your Laravel project, you need to reference it in your blade file where you want to display the component.

@livewire('to-do-list')

Usage

Once the component is integrated into your Laravel application, users can interact with it by adding new tasks, marking tasks as complete or incomplete, editing existing tasks, and deleting tasks.

Configuration and Customization

For customization, you can modify the ToDoList.php file and the to-do-list.blade.php file. You can alter the way tasks are displayed, the order in which they appear, and the fields that are required for a task. Be aware that any modifications could affect the functionality of the component, so proceed with caution and test thoroughly after making changes.

Reusable Dynamic Table Generator using Laravel Livewire

A flexible and reusable Livewire table component that automatically generates tables from any model with built-in sorting, searching, and pagination capabilities. Easily extendable through a simple abstract class implementation, allowing customization of columns, formatting, and behavior while maintaining consistent styling across your application.

UI Stack: Tailwind CSS

DummyProducts

Id ↑ Title Description Price Link Meta Created At Updated At
1 Sony ZX-110 - 14.25 https://amzn.to/3udpeNl {"color":"dark","brand":"sony","connection_type":"wired","type":"overhead","rating":"4.6"} Jun 07, 2021 10:20:12 Jun 07, 2021 10:20:12
2 Apple Airpods Pro - 249 https://amzn.to/34eYwJT {"color":"white","brand":"apple","connection_type":"wireless","type":"earbuds","rating":"4.8"} Jun 07, 2021 10:20:12 Jun 07, 2021 10:20:12
3 Noot Kids K11 - 14.99 https://amzn.to/3fMfogy {"color":"blue","brand":"noot","connection_type":"wired","type":"overhead","rating":"4.9"} Jun 07, 2021 10:20:12 Jun 07, 2021 10:20:12
4 Apple Airpods - 79.99 https://amzn.to/3oNUyRL {"color":"white","brand":"apple","connection_type":"wireless","type":"earbuds","rating":"4.4"} Jun 07, 2021 10:20:12 Jun 07, 2021 10:20:12
5 Tozo T6 Earbuds - 35.87 https://amzn.to/3wzkkfw {"color":"green","brand":"tozo","connection_type":"wireless","type":"earbuds","rating":"2.4"} Jun 07, 2021 10:20:12 Jun 07, 2021 10:20:12
6 Tozo T10 Earbuds - 27.87 https://amzn.to/3oLhql4 {"color":"orange","brand":"tozo","connection_type":"wireless","type":"earbuds","rating":"3.6"} Jun 07, 2021 10:20:12 Jun 07, 2021 10:20:12
7 Cowin E7 - 59.99 https://amzn.to/3wA9C8a {"color":"red","brand":"Cowin","connection_type":"wireless","type":"overhead","rating":"4.4"} Jun 07, 2021 10:20:12 Jun 07, 2021 10:20:12
8 Cowin E7 - 59.99 https://amzn.to/3oOw0Z0 {"color":"purple","brand":"Cowin","connection_type":"wireless","type":"overhead","rating":"4.2"} Jun 07, 2021 10:20:12 Jun 07, 2021 10:20:12
9 Cowin E7 - 59.99 https://amzn.to/3vm29cH {"color":"yellow","brand":"Cowin","connection_type":"wireless","type":"overhead","rating":"4.2"} Jun 07, 2021 10:20:12 Jun 07, 2021 10:20:12
10 Beats Earbuds - 35.63 https://amzn.to/3ujye3J {"color":"black","brand":"beats","connection_type":"wireless","type":"earbuds","rating":"3.3"} Jun 07, 2021 10:20:12 Jun 07, 2021 10:20:12

Code

Sorry, this component's code is restricted
Sorry, this component's code is restricted
Sorry, this component's code is restricted

Overview

The Dynamic Table component is a powerful and flexible Livewire component that automatically generates data tables from your Laravel models. It provides built-in features like sorting, searching, and pagination while maintaining a clean and consistent design. The component is designed to be easily extensible through inheritance, allowing you to customize its behavior while keeping the core functionality intact.

Implementation

Follow these steps to implement the Dynamic Table component:

  • Copy the AbstractDynamicTable.php file to your app/Livewire/Components/Table directory.
  • Copy the dynamic-table.blade.php file to your resources/views/livewire/components/table directory.
  • Create a new Livewire component that extends AbstractDynamicTable for each table you want to implement.

Integration

To create a new table for your model, create a new Livewire component that extends the AbstractDynamicTable class:

php artisan make:livewire Tables/UsersTable

Then implement the required method in your new component:

namespace App\Livewire\Tables;
use App\Models\User;
use App\Livewire\Components\Table\AbstractDynamicTable;
class UsersTable extends AbstractDynamicTable
{
protected function model(): string
{
return User::class;
}
}

Finally, include your table component in your Blade view:

@livewire('tables.users-table')

Usage

The Dynamic Table component provides several features out of the box:

  • Automatic column detection from your model
  • Sortable columns (click column headers to sort)
  • Search functionality across all visible columns
  • Pagination with customizable items per page
  • Responsive design that works on all screen sizes

Configuration

You can customize various aspects of the table by overriding methods in your component:

class UsersTable extends AbstractDynamicTable
{
// Required: Specify the model
protected function model(): string
{
return User::class;
}
// Optional: Customize visible columns
protected function columns(): array
{
return ['name', 'email', 'created_at'];
}
// Optional: Hide specific columns
protected function hiddenColumns(): array
{
return ['password', 'remember_token'];
}
// Optional: Custom column formatting
protected function formatColumnValue($row, string $column): string
{
return match($column) {
'created_at' => $row->created_at->format('M d, Y H:i:s'),
default => parent::formatColumnValue($row, $column)
};
}
// Optional: Customize the query
protected function query(): Builder
{
return parent::query()->where('active', true);
}
}

The component also supports customization of the following properties:

  • $perPage: Number of items to show per page (default: 10)
  • $sortField: Default column to sort by (default: 'id')
  • $sortDirection: Default sort direction (default: 'asc')

Sortable Table Component using Laravel Livewire

Sortable Table Component using Laravel Livewire

UI Stack: Tailwind CSS

Drag Task Created Current Order
Task 1
Mar 31, 2025
1
Task 2
Mar 31, 2025
2
Task 3
Mar 31, 2025
3
Task 4
Mar 31, 2025
4
Task 5
Mar 31, 2025
5

Code

Sorry, this component's code is restricted
Sorry, this component's code is restricted
Sorry, this component's code is restricted
Sorry, this component's code is restricted

Overview

The SortableTaskTable component is a Laravel Livewire implementation that enables drag-and-drop reordering of table rows. It uses SortableJS for smooth drag-and-drop functionality and maintains the order state in the database. The component provides real-time visual feedback of the current sort order.

Implementation Instructions

1. First, add the SortableJS script to your layout file:
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js"></script>
Copy the component files to their respective directories:
app/Livewire/SortableTaskTable.php
resources/views/livewire/sortable-task-table.blade.php
Run the migration to add the sort_order column:
php artisan migrate

Integration

To use the SortableTaskTable component in your blade views, add the following directive:

@livewire('sortable-task-table')

Features

  • Drag-and-drop reordering of table rows
  • Real-time order updates
  • Visual feedback during dragging
  • Automatic order persistence in database
  • Display of current sort order

Event Handling

The component listens for the following events:

// Triggered when items are reordered
Livewire.dispatch('tasks-sorted', { orderedIds: items })

Customization

The component can be customized in several ways:

Modify the drag handle appearance:
// In sortable-task-table.blade.php
<div class="handle tw-cursor-move tw-text-gray-400 hover:tw-text-gray-600">
// Your custom handle icon
</div>
Customize the SortableJS options:
new Sortable(this.$el, {
animation: 150,
handle: '.handle',
ghostClass: 'tw-opacity-50',
dragClass: 'tw-bg-gray-50',
// Add your custom options here
})
Modify the sort order display:
<span class="tw-inline-flex tw-items-center tw-justify-center tw-h-8 tw-w-8 tw-rounded-full tw-bg-gray-100 tw-text-gray-800 tw-font-medium">
{{ $task['sort_order'] }}
</span>

Important Notes

  • The component requires SortableJS to be loaded before it can function
  • All Tailwind classes are prefixed with 'tw-' for compatibility
  • The component assumes the existence of a 'sort_order' column in your table
  • The component automatically handles order updates when items are dragged

Livewire export Table Data to PDF, CSV, XML

export data to pdf, xls or csv without page refresh

UI Stack: Tailwind CSS

Livewire Export Data Demo (Export to CSV, PDF, XLS)

Tasks List

Name Slug
Task 1
Task 2
Task 3
Task 4
Task 5

Code

Sorry, this component's code is restricted
Sorry, this component's code is restricted

Overview

This component provides a dynamic data table with export functionality. Its key features include fetching tasks data from a database, displaying them in a table format, and enabling the user to select multiple rows and export them to CSV, XLS, or PDF formats.

Installation

Follow these steps to implement the component:
  • Copy the component file ExportableDataTableComponent.php to your app/Livewire directory.
  • Copy the blade view file exportable-data-table-component.blade.php to your resources/views/livewire directory.

Integration

After placing the files in the correct directories, use the Livewire component in any blade file by adding the following line:

@livewire('exportable-data-table-component')

Usage

The data table will automatically load the tasks from the DummyTask model and display them in a table. You can select multiple rows and click on the corresponding button to export the selected rows to CSV, XLS, or PDF.

Configuration and Customization

You can customize the behaviour of the data table by modifying the ExportableDataTableComponent component in the app/Livewire directory. For instance, you can change the model from which the data are fetched, the columns displayed in the table, or the export formats available.

You can also modify the look and feel of the data table by editing the exportable-data-table-component.blade.php view in the resources/views/livewire directory.