Skip to content

Columns

Columns declare what each row shows. Create one with Column::make(), passing the key — the row field it reads. Lattice ships a column type for each common value; this page covers the options every column shares.

TextColumn::make('name'); // header "Name", reads $row['name']
TextColumn::make('name')->label('Full name');
  • Text — a value as text, with date, link, and badge modifiers.
  • Number — a formatted number, right-aligned.
  • Money — a currency amount.
  • Boolean — a check or cross.
  • Badge — a coloured pill.
  • Icon — an icon, optionally per value.
  • Image — an image or avatar.
  • Stack — several columns stacked in one cell.

The options below extend the base Column, so they work on every type. The examples use TextColumn, but the methods are identical everywhere.

The label defaults to the humanized key; override it with ->label(). Pass an empty string to render a column with no header — useful for an avatar or icon column.

TextColumn::make('created_at')->label('Registered');

->align(ColumnAlign::Start|Center|End) sets the cell alignment. Text columns default to Start; number and money columns default to End.

use Lattice\Table\Enums\ColumnAlign;
TextColumn::make('code')->align(ColumnAlign::Center);

Every column carries a width hint the table uses to size its column. ->width() overrides the default with a ColumnWidth case (Lattice\Ui\Enums\ColumnWidthXs, Sm, Md, Lg, Xl).

use Lattice\Ui\Enums\ColumnWidth;
TextColumn::make('id')->width(ColumnWidth::Xs);
TextColumn::make('description')->width(ColumnWidth::Xl);

->toggleable() lets viewers show or hide the column from a Columns menu in the table toolbar. The menu appears as soon as at least one column opts in; columns without ->toggleable() stay pinned and never appear in it. Pass hiddenByDefault: true to ship a column hidden — viewers can reveal it when they need it.

TextColumn::make('name')->label('Name'); // pinned, always visible
TextColumn::make('sku')->label('SKU')->toggleable(); // hide-able, shown by default
NumberColumn::make('price')->label('Price')->toggleable();
TextColumn::make('updated_at')->label('Updated')
->dateTime()
->toggleable(hiddenByDefault: true); // hide-able, starts hidden

->pinned() keeps a column fixed at the left edge of the table while the rest of the columns scroll underneath it — useful for an identifying column like a SKU or name in a wide table. Pass ColumnPin::Right to pin a column to the right edge instead.

use Lattice\Table\Enums\ColumnPin;
TextColumn::make('sku')->label('SKU')->pinned(); // pinned left
BadgeColumn::make('status')->label('Status')->pinned(ColumnPin::Right); // pinned right
TextColumn::make('sku')->label('SKU')->pinned();
TextColumn::make('name')->label('Name');
NumberColumn::make('price')->label('Price');
BadgeColumn::make('status')->label('Status')
->colors(['active' => 'green', 'archived' => 'gray'])
->pinned(ColumnPin::Right);

The row-selection checkbox and the row-actions column pin themselves automatically whenever any data column is pinned, so they stay reachable at the edge nearest their side.

Enable ->pinnableColumns() on the table definition to let viewers pin and unpin columns themselves, alongside show/hide, from the Columns menu:

public function pinnableColumns(): bool
{
return true;
}

->sortable() and ->filterable() are capabilities a column opts into, not display options. They add the sort control and the filter affordance to the header, and tell the data source to apply the request’s sort and filter for that column. They are covered under Sorting & pagination and Filtering.

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