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
| Argument | Description | Default |
|---|---|---|
resource | The Eloquent model class or Query Builder 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. | [15, 30, 50, 100] |
defaultSort | The default sort column for the table. | null |
transformModelUsing | A closure to transform the model data. | null |
withQueryBuilder | A closure to interact with the Query Builder. | null |
emptyState | The empty state configuration for the table. | null |
stickyHeader | Whether to make the table header sticky. | null |
defaultPerPage | The default per page value for the table. | null |