Beartropy Tables

Columns
Define and customize table columns with powerful modifiers for styling, data transformation, sorting, searching, and responsive behavior.

Defining Columns

Columns are created using Column::make() and returned as an array from the columns() method.

Basic Column Definition

Column::make(string $label, ?string $field) — The $label is the header text, and $field maps to the data key. If $field is omitted, the label is used as the key.

1public function columns(): array {
2 return [
3 Column::make('Name','name')
4 ->styling('text-lg font-bold')
5 ->hideFromSelector(true),
6 
7 Column::make('Hex Code','hex'),
8 
9 Column::make('Color')
10 ->customData(function($row, $value){
11 return '<span style="color:'.$row['hex'].'">██████████████</span>';
12 })
13 ->toHtml(),
14 
15 LinkColumn::make('Google it','name')
16 ->href(function($row, $value){
17 return "https://www.google.com/search?q=".$value;
18 })
19 ->text('Google'),
20 
21 BoolColumn::make('Primary','isPrimary')
22 ];
23}

Cell Styling

Customize the visual appearance of column cells and headers.

Cell Classes

styling(string $classes) — Add Tailwind classes to all <td> elements in the column. Classes are prefixed with ! to override conflicting styles.

1Column::make('Big text column','bigtext')
2 ->styling('text-7xl')

Header Styling

thStyling(string $classes) — Add classes to the <th> element.
thWrapperStyling(string $classes) — Add classes to the inner wrapper div of the header cell.

1Column::make('Large Header','name')
2 ->thStyling('text-xl text-red-500')
3 ->thWrapperStyling('p-4 border-b-2 border-red-500')

Content Alignment

pushLeft() / pushRight() — Align both the header and content to the left or right. Useful for numeric data and currency columns.

1Column::make('Price', 'price')
2 ->pushRight() // Aligns header and content to the right
3 
4Column::make('Status', 'status')
5 ->pushLeft() // Aligns header and content to the left
Beartropy Logo

© 2026 Beartropy. All rights reserved.

Provided as-is, without warranty. Use at your own risk.