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(), ];}Choose a cell type
Section titled “Choose a cell type”| 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',]);Format numbers and currencies
Section titled “Format numbers and currencies”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.
Show a related field
Section titled “Show a related field”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.
Enable controls
Section titled “Enable controls”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.
Transform values
Section titled “Transform values”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.
Infer columns from a model
Section titled “Infer columns from a model”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 context
Section titled “Callback context”Callback parameters are injected by name or object type. See the callback reference for the complete argument list and resolution rules.