Skip to content

Number column

NumberColumn right-aligns its cell and formats the value as a number for the viewer’s locale. It is sortable and filters as a number.

TextColumn::make('label')->label('Metric');
NumberColumn::make('views')->label('Views')->compact()->sortable();
NumberColumn::make('conversion')->label('Conversion')
->unit(NumberFormatUnit::Percent)
->decimals(1);
  • ->decimals($min, $max?) fixes the fraction digits — ->decimals(2) for exactly two, or ->decimals(0, 2) for a min–max range.
  • ->unit(NumberFormatUnit::…) adds a locale-correct unit suffix — Percent, Kilogram, Byte, and the rest of the NumberFormatUnit cases. The value is rendered as-is with the unit appended — no scaling — so store 12.8 to render 12.8%.
  • ->compact() renders large numbers compactly (1.2K, 3.4M).
  • ->copyable() adds a click-to-copy affordance. It copies the raw value (1234.5), not the formatted text — what you want when pasting into a spreadsheet.
use Lattice\Ui\Enums\NumberFormatUnit;
NumberColumn::make('weight')->unit(NumberFormatUnit::Kilogram)->decimals(1);
NumberColumn::make('downloads')->compact();

For a currency amount, reach for the dedicated Money column.