Filters are rules that reduce the number of objects visible on screen at one time, and are often used to reduce visual clutter and focus only on the objects that matter to the user. Use a filter when:
- Objects in the view have attributes such as names, statuses, colors, etc. by which they can be identified and organized
- Objects to be filtered are contained within a single page or view rather than spread throughout multiple sections of the application
- Objects in the view are independent and make sense regardless of their position on the page or relative to other objects
- If you need to locate objects while preserving their positions on the page, use find instead
Filter is often displayed as a component of the toolbar, and can be paired with one of several filter triggers
Textbox filter (single attribute)
Textbox filter (multiple attributes)
Filter with inline active filters
The filter trigger is a component that adds active filters to a page. It is located on the left side of the page, often within the toolbar. A filter trigger may be a simple text box or something much more complicated. Only one type of filter trigger should be used on a given page. Possible filter triggers include:
Active Filters Bar
- Filter Chips: Filters are labeled with the attribute and value used to create them. Clicking the X in the chip will remove the filter. New filters appear to the right of existing filters. If no active filters exist, the active filters bar may be hidden.
- Grouped Filter Chips (optional): In some cases, filters may have more than one value for a given attribute. When this happens, the values are shown grouped together . They may be removed separately by clicking on their respective Xs.
- Clear All Filters: Clicking this action removes all currently active filters.
- Items Count: The number of items that match the currently active filters and the number of total items in the view should be displayed next to the active filters. If there are no active filters, only the total number of items should be shown. The term “Items” should be used as a default label unless there is a more descriptive label that can be applied to the objects on the page (e.g. “28 cars”)
- Inline Active Filters (optional): If filtering is used without any of the other elements of the toolbar, active filters can be displayed inline to save vertical space
- Filters between attribute categories should be combined with a boolean AND operator
- Example an item must be both a car AND blue to be shown in the list of results
- Filters within a category are shown grouped together and should be combined with a boolean OR operator
- Example Items can be blue OR green and still be shown in the list of results
- If the list is not otherwise sorted, items that satisfy a higher number of filters should be shown higher up the page.
- Example Items that are blue as well as green are listed before items that are only blue or only green.
Displaying a Null Result Set
If the current set of active filters returns 0 results, an empty state message will appear within the current view.
- Message: Alert user that there are 0 results based on the filter criteria
- Suggestions: A brief message suggesting how to fix the problem.
- Clear All Filters: Clicking this will clear all applied filters and restore content to this view.
- Background: The background color of this form will match the color of the current view. Note that in Table View, the background color is white.
This message will always be displayed within the current view and the Toolbar will remain active so that the user can modify filter criteria.
Null Results in Table View
PatternFly Core Example Not Available
There is no PatternFly-Core code available for this pattern at this time. Links to the JS framework implementations can be seen above.
Visit the Contributing to PatternFly documentation to learn how to contribute the code.