Skip to main content
You are currently viewing the documentation for Filament 2.x, which is a previous version of Filament.Looking for the current stable version? Visit the 5.x documentation.

Getting started

Filters allow you to scope the Eloquent query as a way to reduce the number of records in a table. If you’re using the filters in a Livewire component, you can put them in the getTableFilters() method:
If you’re using them in admin panel resources or relation managers, you must put them in the $table->filters() method:
Filters may be created using the static make() method, passing its name. The name of the filter should be unique. You should then pass a callback to query() which applies your filter’s scope:

Setting a label

By default, the label of the filter, which is displayed in the filter form, is generated from the name of the filter. You may customize this using the label() method:
Optionally, you can have the label automatically translated by using the translateLabel() method:

Using a toggle button instead of a checkbox

By default, filters use a checkbox to control the filter. Instead, you may switch to using a toggle button, using the toggle() method:

Default filters

You may set a filter to be enabled by default, using the default() method:

Filter forms

By default, filters have two states: enabled and disabled. When the filter is enabled, it is applied to the query. When it is disabled it is not. This is controlled through a checkbox. However, some filters may require extra data input to narrow down the results further. You may use a custom filter form to collect this data.

Select filters

Select filters allow you to quickly create a filter that allows the user to select an option to apply the filter to their table. For example, a status filter may present the user with a few status options to pick from and filter the table using:
Select filters do not require a custom query() method. The column name used to scope the query is the name of the filter. To customize this, you may use the attribute() method:

Multi-select filters

These allow the user to select multiple options to apply the filter to their table. For example, a status filter may present the user with a few status options to pick from and filter the table using:

Relationship select filters

Select filters are also able to automatically populate themselves based on a BelongsTo relationship. For example, if your table has a author relationship with a name column, you may use relationship() to filter the records belonging to an author:
You may customize the database query that retrieves options using the third parameter of the relationship() method:

Ternary filters

Ternary filters allow you to quickly create a filter which has three states - usually true, false and blank. To filter a column named is_admin to be true or false, you may use the ternary filter:
Another common pattern is to use a nullable column. For example, when filtering verified and unverified users using the email_verified_at column, unverified users have a null timestamp in this column. To apply that logic, you may use the nullable() method:
The column name used to scope the query is the name of the filter. To customize this, you may use the attribute() method:
You may customize the query used for each state of the ternary filter, using the queries() method:

Custom filter forms

You may use components from the Form Builder to create custom filter forms. The data from the custom filter form is available in the $data array of the query() callback:

Setting default values

If you wish to set a default filter value, you may use the default() method on the form component:

Active indicators

When a filter is active, an indicator is displayed above the table content to signal that the table query has been scoped. By default, the label of the filter is used as the indicator. You can override this:

Custom indicators

Not all indicators are simple, so you may need to use indicateUsing() to customize which indicators should be shown at any time. For example, if you have a custom date filter, you may create a custom indicator that formats the selected date:
You may even render multiple indicators at once, by returning an array. If you have different fields associated with different indicators, you should use the field’s name as the array key, to ensure that the correct field is reset when the filter is removed:

Appearance

By default, filters are displayed in a thin popover on the right side of the table, in 1 column. To change the number of columns that filters may occupy, you may use the getTableFiltersFormColumns() method:
Adding more columns to the filter form will automatically widen the popover. To customize the popover width, you may use the getTableFiltersFormWidth() method, and specify a width from xs to 7xl:

Displaying filters above or below the table content

To render the filters above the table content instead of in a popover, you may use:
To render the filters below the table content instead of in a popover, you may use:

Persist filters in session

To persist the table filters in the user’s session, use the shouldPersistTableFiltersInSession() method: