Beartropy Tables

Options
Add custom dropdown actions to the table toolbar for bulk operations, exports, and more.

Defining Options

Return an array of actions from the options() method to create a dropdown menu.

Simple Options

The options() method returns an array where keys are method names and values are display labels. Clicking an option triggers wire:click on the matching method.

1public function options(): array {
2 return [
3 'export' => 'Export selected rows',
4 'remove' => 'Delete selected rows',
5 ];
6}
7 
8public function remove() {
9 foreach ($this->getSelectedRows() as $id) {
10 $this->removeRowFromTable($id);
11 }
12}

Options with Icons

For richer dropdown items, use an array with label and icon keys instead of a plain string.

1public function options(): array {
2 return [
3 'exportSelected' => ['label' => 'Export to Clipboard', 'icon' => '📋'],
4 'deactivateSelected' => ['label' => 'Deactivate Selected', 'icon' => '🚫'],
5 'deleteSelected' => ['label' => 'Delete Selected', 'icon' => '🗑️'],
6 ];
7}

Implement your methods

Every key in the options() array must have a corresponding public method on your table component. Missing methods will cause a Livewire error when the option is clicked.

Export Helpers

Data accessor methods available for building export actions.

Data Access for Export

Use these methods inside your option handlers to access the dataset. Combine with exportToClipboard() or Laravel Excel for export workflows.

1$this->getAllData(); // Collection of all data
2$this->getAfterFiltersData(); // Collection of filtered data
3$this->getSelectedData(); // Collection of selected rows

Laravel Excel auto-detection

If Laravel Excel is installed, "Export to Excel" and "Export to CSV" options are added to the settings dropdown automatically.

Complete Example

A playground table with bulk selection and multiple option actions.

BulkUsersTable.php

This example shows a complete table with bulk selection enabled, three dropdown actions (export, deactivate, delete), and proper empty-selection guards.

1use App\Models\User;
2use Beartropy\Tables\Classes\Columns\Column;
3use Beartropy\Tables\Classes\Columns\DateColumn;
4use Beartropy\Tables\YATBaseTable;
5 
6class BulkUsersTable extends YATBaseTable
7{
8 public $model = User::class;
9 
10 public function columns(): array
11 {
12 return [
13 Column::make('Name', 'name')->sortable()->searchable(),
14 Column::make('Email', 'email')->sortable()->searchable(),
15 DateColumn::make('Created', 'created_at')
16 ->outputFormat('M d, Y'),
17 ];
18 }
19 
20 public function options(): array
21 {
22 return [
23 'exportSelected' => ['label' => 'Export to Clipboard', 'icon' => '📋'],
24 'deactivateSelected' => ['label' => 'Deactivate Selected', 'icon' => '🚫'],
25 'deleteSelected' => ['label' => 'Delete Selected', 'icon' => '🗑️'],
26 ];
27 }
28 
29 public function exportSelected(): void
30 {
31 $data = $this->getSelectedData();
32 if ($data->isEmpty()) {
33 $this->dispatch('toast', message: 'No rows selected.', type: 'warning');
34 return;
35 }
36 $this->exportToClipboard($data);
37 $this->dispatch('toast', message: $data->count() . ' rows copied.', type: 'success');
38 }
39 
40 public function deactivateSelected(): void
41 {
42 $ids = $this->getSelectedRows();
43 if (empty($ids)) { return; }
44 User::whereIn('id', $ids)->update(['email_verified_at' => null]);
45 $this->emptySelection();
46 }
47 
48 public function deleteSelected(): void
49 {
50 $ids = $this->getSelectedRows();
51 if (empty($ids)) { return; }
52 User::whereIn('id', $ids)->delete();
53 $this->emptySelection();
54 }
55 
56 public function settings(): void
57 {
58 $this->hasBulk(true);
59 $this->showOptionsOnlyOnRowSelect();
60 $this->setPerPageDefault(15);
61 }
62}

Live Demo

Try it — select rows with checkboxes, then use the dropdown options.

Options & Bulk Actions

Bulk Actions
#
Name
Email
Role
Created
1
Alice Johnson alice@example.com Admin Jan 15, 2024
2
Bob Smith bob@example.com Editor Feb 20, 2024
3
Carol White carol@example.com Viewer Mar 10, 2024
4
David Brown david@example.com Editor Apr 05, 2024
5
Eva Martinez eva@example.com Admin May 22, 2024
6
Frank Lee frank@example.com Viewer Jun 18, 2024
7
Grace Kim grace@example.com Editor Jul 03, 2024
8
Henry Davis henry@example.com Admin Aug 29, 2024
1<livewire:tables.demos.demo-bulk-table />
Beartropy Logo

© 2026 Beartropy. All rights reserved.

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