TextColumn
The column for almost everything: text, labels, badges, yes/no, dates, numbers, amounts, referenced records and users. The value is formatted by one format option; the options of every column apply as well.
use Anvil\Collection\Columns\TextColumn;
TextColumn::make('title')->limit(60)->searchable(),TextColumn::make('status')->labels(['open' => 'Open', 'done' => 'Done'])->badge(['done' => 'success']),TextColumn::make('is_active')->label('Active')->boolean(),TextColumn::make('due_on')->date()->sortable(),TextColumn::make('due_on')->relative(),TextColumn::make('budget')->money('EUR')->sortable(),TextColumn::make('hours')->numeric(1),TextColumn::make('customer_id')->label('Customer')->relationship(CustomerModel::class, 'name')->linkToRecord(),TextColumn::make('owner_id')->label('Owner')->user(),Formats
Section titled “Formats”| Option | Shows | Notes |
|---|---|---|
| (none) | the value as text | true/false as “Yes”/“No” |
labels([value => label]) |
a label instead of the stored code | values without a label are shown as they are; combinable with badge() and limit() |
badge([value => colour]) |
the (labelled) value as a badge | colours: primary, secondary, success, danger, warning, info, light, dark; unknown values are secondary; other colours throw an InvalidArgumentException |
boolean() |
a green check or a grey cross | true, 1, "1" are yes; screen readers read “Yes”/“No” |
date() |
a date in the format of the user’s language (05.11.2026, Nov 5, 2026) |
date('d.m.Y') for a fixed PHP date format; accepts DATE/DATETIME strings and DateTime objects |
dateTime() |
date and time in the format of the user’s language (05.11.2026, 14:30) |
dateTime('d.m.Y H:i') for a fixed format |
relative() |
“today”, “in 3 days”, “12 days ago” | whole days relative to today |
numeric(2) |
a number in the format of the locale (1.234,5) |
right aligned |
money('EUR', 2) |
an amount in the format of the locale (1.234,50 €) |
right aligned; ISO 4217 code |
limit(60) |
text shortened to n characters with “…” | applies to plain text and labels |
relationship(Model::class, 'name') |
the title of the record a foreign key points to | see Relationships |
user() |
the username for the id of a user | see Relationships |
linkToRecord() |
with relationship(): the title links to the detail page |
see Relationships |
Only one of badge(), boolean(), date()/dateTime(), relative(),
numeric() and money() applies – the last one called wins.
relationship() and user() take precedence over all formats.
Empty values
Section titled “Empty values”null and '' render nothing (no “—”), in every format. A value that
cannot be formatted (a date that cannot be parsed, a non-numeric value in
a numeric() column) is shown empty as well.
Examples
Section titled “Examples”// Status codes with labels and coloursTextColumn::make('approval_state')->label('Approval') ->labels(['draft' => 'Draft', 'submitted' => 'Submitted', 'approved' => 'Approved', 'rejected' => 'Rejected']) ->badge(['approved' => 'success', 'rejected' => 'danger', 'submitted' => 'info']),
// A date with an icon, hidden until the user shows itTextColumn::make('exit_date')->date()->icon('box-arrow-right')->toggleable(hidden: true),
// Long text with the e-mail address as second lineTextColumn::make('name')->limit(40)->description('email')->searchable(),
// Negative amounts in redTextColumn::make('balance')->money('EUR')->color(fn ($balance) => $balance < 0 ? 'danger' : null),Sorting and searching
Section titled “Sorting and searching”Sorting and searching use the stored value, not the formatted text: a
labels() column sorts by the code, a relationship() column by the
foreign key. Search the title of a related record with a join and
queryColumn(), see Computed values.
Exports
Section titled “Exports”numeric() and money() export numbers, boolean() “Yes”/“No”,
all other formats the text shown in the list (labels, formatted dates,
titles of related records).