Skip to content

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

ArgumentDescriptionDefault
resourceThe Eloquent model class to use as the table's resource.
columnsAn array of column classes to use in the table.[]
filtersAn array of filter classes to use in the table.[]
searchAn array of attributes to search on.[]
nameThe name of the table.'default'
paginationWhether to enable pagination.true
debounceTimeThe debounce time in milliseconds for the search input.300
perPageOptionsThe per page options to use in the pagination dropdown.[10, 25, 50, 100]