Columns
Add columns with a field key and an optional label:
use InertiaX\Components\Table\Columns\NumberColumn;use InertiaX\Components\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\Components\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',]);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');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”InertiaX::table('users')->data($users)->autoColumns();autoColumns() infers the model’s allowed fields. Explicitly added columns take precedence over
inference for the same key. Use AutoColumn::make('score')->sortable() to infer just one field.
See Column API for options, defaults, and inference rules.