Skip to content

Anonymous Table Builder

The Anonymous Table Builder lets you spin up an Inertia Table inline from a controller via the static Table::build() method, without writing a dedicated Table class. It's the fastest way to render a simple table, but Row Actions and Exports are not supported, so reach for a dedicated Table class as soon as you need either.

Usage

You may define a table using the static build method of the Table class. It takes named arguments for configuration. Only resource and columns are required.

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 or Query Builder 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.[15, 30, 50, 100]
defaultSortThe default sort column for the table.null
transformModelUsingA closure to transform the model data.null
withQueryBuilderA closure to interact with the Query Builder.null
emptyStateThe empty state configuration for the table.null
stickyHeaderWhether to make the table header sticky.null
defaultPerPageThe default per page value for the table.null