Skip to content

Commit a485d2f

Browse files
committed
Update docs
1 parent 9a65ba5 commit a485d2f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/columns/other-column-types.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,28 @@ ButtonGroupColumn::make('Actions')
159159
}),
160160
]),
161161
```
162+
163+
## Component Columns
164+
165+
Component columns let you specify a component name and attributes and provides the column value to the slot.
166+
167+
```php
168+
// Before
169+
Column::make("Email", "email")
170+
->format(function ($value) {
171+
return view('components.alert')
172+
->with('attributes', new ComponentAttributeBag([
173+
'type' => Str::endsWith($value, 'example.org') ? 'success' : 'danger',
174+
'dismissible' => true,
175+
]))
176+
->with('slot', $value);
177+
}),
178+
179+
// After
180+
ComponentColumn::make('E-mail', 'email')
181+
->component('email')
182+
->attributes(fn ($value, $row, Column $column) => [
183+
'type' => Str::endsWith($value, 'example.org') ? 'success' : 'danger',
184+
'dismissible' => true,
185+
]),
186+
```

0 commit comments

Comments
 (0)