Multi-Select Dropdown Filters

Multi-select dropdown filters are a simple dropdown list. The user can select multiple options from the list. There is also an 'All' option that will select all values

1use Rappasoft\LaravelLivewireTables\Views\Filters\MultiSelectDropdownFilter;
2 
3public function filters(): array
4{
5 return [
6 MultiSelectDropdownFilter::make('Tags')
7 ->options(
8 Tag::query()
9 ->orderBy('name')
10 ->get()
11 ->keyBy('id')
12 ->map(fn($tag) => $tag->name)
13 ->toArray()
14 )
15 ->setFirstOption('All Tags'),
16 ];
17}

Filter Pills Separator

As this filter returns one or more values, you have the option to utilise a custom separator for the values displayed in the Filter Pills section at the top of the table. The default is ", ", but you may use any HTML string to separate the selected values

1public function filters(): array
2{
3 return [
4 MultiSelectFilter::make('Tags')
5 ->options(
6 Tag::query()
7 ->orderBy('name')
8 ->get()
9 ->keyBy('id')
10 ->map(fn($tag) => $tag->name)
11 ->toArray()
12 )
13 ->setPillsSeparator('<br />'),
14 ];
15}