Skip to content

Getting Started with Columns

Learn about the column system in Inertia Tables and how to configure different column types.

Columns are the fundamental building blocks of your data tables. They define how your data is displayed, formatted, and interacted with. Inertia Tables provides a flexible column system that allows you to customize every aspect of your table’s appearance and behavior.

Column classes can be found in the Egmond\InertiaTables\Columns namespace. You can put them inside the $table->columns() method:

use Egmond\InertiaTables\Table;
public function table(Table $table): Table
{
return $table
->columns([
// ...
]);
}

All columns in Inertia Tables extend from the BaseColumn class and follow a consistent API pattern:

use Egmond\InertiaTables\Columns\TextColumn;
TextColumn::make('name')

Inertia Tables currently provides the following column types:

More column types are planned for future releases.

All columns are created using the static make() method, which accepts the column name as its parameter:

TextColumn::make('name') // Simple column
TextColumn::make('user.name') // Relationship column
TextColumn::make('posts_count') // Computed/aggregated column

The column name should correspond to:

  • A column in your database table
  • An accessor on your model
  • A relationship using dot notation

By default, the column label is automatically generated from the column name. You can customize it:

TextColumn::make('created_at')
->label('Date Created')

Control column visibility:

TextColumn::make('email')
->visible(true) // Visible
->hidden(false) // Visible
->visible(false) // Always hidden
->hidden(true) // Always hidden
->visible(fn() => auth()->user()->isAdmin()) // Conditional visibility

Enable sorting on columns:

TextColumn::make('name')
->sortable()

Make columns searchable:

TextColumn::make('name')
->searchable()

You can easily display relationship data using dot notation:

TextColumn::make('author.name')
->label('Author')
->searchable()
->sortable()

Columns support method chaining for clean, readable configuration:

TextColumn::make('email')
->label('Email Address')
->searchable()
->sortable()
->copyable()
->limit(30)
->wrap('truncate')

Make columns behave differently based on conditions:

TextColumn::make('name')
->searchable(fn () => auth()->user()->can('search-users'))
->sortable(fn () => request()->has('sort'))

Now that you understand the basics of columns, explore specific column types and their features:

  • Text Column - Learn about all TextColumn features and customization options