Text Column
TextColumn is the most versatile and commonly used column type in Kinetics. It is used to display strings, numbers, dates, or even transform text into visual badges.
Basic Usage
Section titled “Basic Usage”Use the static make() method with the attribute name from your database.
use Kinetics\Columns\TextColumn;
TextColumn::make('title')Relationships
Section titled “Relationships”You can access properties from Eloquent relationships using dot notation. For example, if your Post model has an author() relationship, and you want to display the author’s name:
TextColumn::make('author.name')->label('Author')Searching and Sorting
Section titled “Searching and Sorting”TextColumn is a prime candidate for the search (searchable()) and sort (sortable()) features.
TextColumn::make('title') ->sortable() ->searchable()Formatting Dates & Times
Section titled “Formatting Dates & Times”Kinetics provides built-in methods to easily format your created_at, updated_at, or any date columns without needing a custom format closure. It automatically uses Carbon behind the scenes.
date()
Section titled “date()”Formats the column as a date. Default format is Y-m-d.
TextColumn::make('created_at')->date('d M Y') // Output: 17 Jun 2026time()
Section titled “time()”Formats the column as a time. Default format is H:i:s.
TextColumn::make('created_at')->time('H:i') // Output: 13:00dateTime()
Section titled “dateTime()”Formats the column as both date and time. Default format is Y-m-d H:i:s.
TextColumn::make('created_at')->dateTime('d M Y H:i')Badges and Colors
Section titled “Badges and Colors”Instead of creating a separate column type for statuses, you can transform any TextColumn into a Badge component natively.
Enabling Badge Mode
Section titled “Enabling Badge Mode”Use the badge() method. You can also pass a boolean condition to dynamically decide if it should be rendered as a badge.
TextColumn::make('status') ->label('Order Status') ->badge()Dynamic Colors
Section titled “Dynamic Colors”The true power of badges lies in the color() method. It allows you to assign specific shadcn/ui color variants based on the row’s exact value.
Supported color variants: 'default', 'secondary', 'destructive', 'outline', 'ghost', 'link'.
1. Static Color
Section titled “1. Static Color”Apply a single color to all badges in this column.
TextColumn::make('role') ->badge() ->color('secondary')2. Value-based Color Mapping
Section titled “2. Value-based Color Mapping”Pass an array to map specific column values to specific color variants. This is perfect for status columns!
TextColumn::make('status') ->badge() ->color([ 'published' => 'default', 'draft' => 'secondary', 'deleted' => 'destructive', ])API Reference
Section titled “API Reference”| Method | Description |
|---|---|
make(string $key) | Creates a new column instance. |
label(string $label) | Sets the column header label. |
as(string $outputKey) | Sets an alias for the output key. |
sortable(bool $value = true) | Enables sorting for this column. |
searchable(bool $value = true) | Enables searching for this column. |
hidden(bool $value = true) | Hides the column from the table. |
formatUsing(\Closure $cb) | Customizes the output formatting via closure. |
badge(bool $condition = true) | Renders the column data as a badge. |
color(string|array $color) | Sets the badge color. |
date(string $format) | Formats the data as a date. |
time(string $format) | Formats the data as time. |
dateTime(string $format) | Formats the data as datetime. |