Skip to content

Columns

Add columns with a field key and an optional label:

use InertiaX\Table\Columns\NumberColumn;
use InertiaX\Table\Columns\TextColumn;
protected function columns(): array
{
return [
NumberColumn::make('id')->numberCast('int')->visible(false),
TextColumn::make('name', 'Full name')->searchable()->sortable(),
TextColumn::make('email')->copyable(),
];
}
Column Displays
TextColumn Text
NumberColumn Integers or decimals
BooleanColumn A Boolean label and optional icon
DateColumn A date
DateTimeColumn A date and time
TimeColumn A time
JsonColumn Formatted structured data
BadgeColumn A status or category badge

All classes are in InertiaX\Table\Columns.

BooleanColumn::make('active')->trueLabel('Enabled')->falseLabel('Disabled');
DateColumn::make('joined_on', 'Joined')->format('M j, Y');
BadgeColumn::make('status')->variant([
'active' => 'success',
'invited' => 'secondary',
]);
NumberColumn::make('amount_cents', 'Amount')
->numberCast('int')
->currency('USD', divideBy: 100)
->copyable();
NumberColumn::make('ratio')->numberCast('decimal')->decimals(3)->locale('fr-FR');

The first column displays 8419 as $84.19 in the cell, title and copied text. Its raw value stays 8419. Formatting defaults to en-US; choose a locale explicitly when needed.

Use int for integer units and decimal for exact decimal strings. Formatting cannot recover precision already lost by a float cast. Filters still accept stored units: label a cents filter Amount (cents). See Number presentation for options and how formatting interacts with value transformers.

For an order’s customer name, use its customer() BelongsTo relation:

TextColumn::make('customer_name', 'Customer')
->relationship('customer', 'name')
->searchable()
->sortable();

On a customer table, use its orders() HasMany relation for totals:

NumberColumn::make('orders_count', 'Orders')->count('orders')->sortable();

See related fields and counts and sums for supported relations and options.

Opt into search, sorting, filtering, copying, or the column picker:

TextColumn::make('email')
->searchable()
->sortable()
->filterable()
->copyable()
->toggleable();

Use wrap() for wrapping text or truncate(80) to shorten a displayed value.

TextColumn::make('name')
->transformUsing(fn (string $value): string => mb_strtoupper($value));
TextColumn::make('role')->mapAs([
'admin' => 'Administrator',
'member' => 'Member',
], default: 'Unknown');

Use $value for the scalar argument: its name matters, and there is no positional injection. Typed record arguments can use any name. See Callback context.

Transformers run on the server when preparing cells. Search and sorting still operate on source values. See Custom columns for row metadata and React renderers.

Table::make('users')->data($users)->autoColumns();

autoColumns() shows the fields the model serializes, as toArray() does: its columns and $appends, without $hidden fields, or only the $visible ones when that list is set. Leave a field out of one table with autoColumns(except: ['internal_notes']). An explicitly added column with the same key replaces the inferred one and appears after the inferred columns. Use AutoColumn::make('score')->sortable() to infer just one field.

See Column API for options, defaults, and inference rules.

Callback parameters are injected by name or object type. See the callback reference for the complete argument list and resolution rules.

View Markdown