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\Lattice\Tables\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\Lattice\Core\Enums\ColumnWidthXs, Sm, Md, Lg, Xl).

use Lattice\Lattice\Core\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'); // pinned, always visible
TextColumn::make('sku')->toggleable(); // hide-able, shown by default
NumberColumn::make('price')->toggleable();
TextColumn::make('updated_at')->label('Updated')
->dateTime()
->toggleable(hiddenByDefault: true); // hide-able, starts hidden

->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();