Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed Dec 19, 2021
1 parent 6be91ec commit 7e87091
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/tables/docs/03-columns.md
Expand Up @@ -133,6 +133,18 @@ use Filament\Tables\Columns\TextColumn;
TextColumn::make('slug')->visibleFrom('md')
```

### Custom attributes

The HTML of columns can be customized, by passing an array of `extraAttributes()`:

```php
use Filament\Tables\Columns\TextColumn;

TextColumn::make('slug')->extraAttributes(['class' => 'bg-gray-200'])
```

These get merged onto the outer `<div>` element of each cell in that column.

## Text column

You may use the `date()` and `dateTime()` methods to format the column's state using [PHP date formatting tokens](https://www.php.net/manual/en/datetime.format.php):
Expand Down
1 change: 1 addition & 0 deletions packages/tables/src/Columns/Column.php
Expand Up @@ -17,6 +17,7 @@ class Column extends Component implements Htmlable
use Concerns\CanBeSortable;
use Concerns\CanCallAction;
use Concerns\CanOpenUrl;
use Concerns\HasExtraAttributes;
use Concerns\HasLabel;
use Concerns\HasName;
use Concerns\HasRecord;
Expand Down
20 changes: 20 additions & 0 deletions packages/tables/src/Columns/Concerns/HasExtraAttributes.php
@@ -0,0 +1,20 @@
<?php

namespace Filament\Tables\Columns\Concerns;

trait HasExtraAttributes
{
protected array $extraAttributes = [];

public function extraAttributes(array $attributes): static
{
$this->extraAttributes = $attributes;

return $this;
}

public function getExtraAttributes(): array
{
return $this->extraAttributes;
}
}

0 comments on commit 7e87091

Please sign in to comment.