Anonymous Table Builder
Introduction
If you don't want to use dedicated Table classes, you can use the Anonymous Table Builder to create simple tables. Note that this builder is not as powerful as the dedicated Table classes. Actions and Exports are not supported.
How to use
You may define a table using the static build
method of the Table
class. It allows you to configure the table using named arguments. Only the resource
and columns
arguments are required, the rest are optional.
php
use App\Models\User;
use InertiaUI\Table\Columns;
use InertiaUI\Table\Filters;
class UsersController
{
public function index()
{
return inertia('Users', [
'users' => Table::build(
resource: User::class,
columns: [
Columns\TextColumn::make('name'),
],
filters: [
Filters\TextFilter::make('name'),
],
),
]);
}
}
Available arguments
Argument | Description | Default |
---|---|---|
resource | The Eloquent model class to use as the table's resource. | |
columns | An array of column classes to use in the table. | [] |
filters | An array of filter classes to use in the table. | [] |
search | An array of attributes to search on. | [] |
name | The name of the table. | 'default' |
pagination | Whether to enable pagination. | true |
debounceTime | The debounce time in milliseconds for the search input. | 300 |
perPageOptions | The per page options to use in the pagination dropdown. | [10, 25, 50, 100] |