magento 2 expand layered navigation

magento 2 expand layered navigation

September 17, 2026 · Illustrated author avatarBy Stefan Bogdanescu
magento 2 expand layered navigation

Expanding Layered Navigation in Magento 2: Step-by-Step Guide

In Magento 2.0, the default layered navigation setup is quite restrictive. By design, only the first filter (usually Prices) is expanded by default while all other filters remain collapsed. This layout can be limiting for users and may not provide the optimal shopping experience.

If you’re looking to expand all your filter options so that each category under every filter is visible, here’s a step-by-step guide to help you achieve this.

Understanding the Default Behavior

Before we dive into the solution, let’s first understand how Magento 2 handles this functionality.

The filter-options-content class is responsible for hiding and showing the filter options. By default, it has a style attribute set to display: none;, which means all filters are hidden except for the one that is expanded.

The aria-expanded="false" attribute indicates that the filter is currently collapsed. When you click on a filter, this attribute changes to true, and the content becomes visible.

Expanding All Filters in Magento 2

To expand all your filters in Magento 2, we need to modify the default behavior of the layered navigation block.

Step 1: Locate the Relevant File

Open your terminal or command prompt and navigate to the root directory of your Magento installation. Then run:

cd app/design/frontend/<Your_Theme>/Magento_LayeredNavigation/templates/layer/view.phtml

Replace <Your_Theme> with the name of your current theme.

Step 2: Modify the View File

Open the view.phtml file in a text editor or IDE. Look for this line of code:

<div id="filter-options-content-<?= $item->getId() ?>" class="filter-options-content" style="display: none;">

We need to remove the style="display: none;" attribute from this div. Change the line to look like this:

<div id="filter-options-content-<?= $item->getId() ?>" class="filter-options-content">

This removes the default hiding behavior of all filter options.

Step 3: Save and Refresh Your Store

Save the changes you made and close the file. Then, flush your Magento cache using one of these methods:

  1. From the admin panel: Go to System > Cache Management, select all types, and click ‘Flush Cache’.

  2. Via SSH or terminal:

php bin/magento cache:flush
  1. Or use a third-party tool like Magento 2 Cache Management extension.

After flushing the cache, refresh your store’s frontend. You should now see that every filter option is expanded by default.

Best Practices for Layered Navigation in Magento 2

While this solution expands all filters, it’s important to consider whether this is actually beneficial for your users and site performance.

Having all filters open can lead to a cluttered user interface if you have many options. It can also slow down page loading times since more data needs to be rendered on the screen.

A better approach might be to keep some filters collapsed by default but allow users to expand them individually as needed. This provides a cleaner look while still offering full functionality.

Conclusion

Expanding all filter options in Magento 2’s layered navigation is a straightforward process that involves modifying a single line of code in your theme files. By following the steps outlined above, you can easily adjust this behavior to suit your specific needs.

Remember, though, while expanding filters can provide more visibility to shoppers, it’s crucial to balance user experience with site performance and layout aesthetics. Always test changes thoroughly before deploying them live.

For a deeper dive into Magento 2 customizations and how our team at Laravel Company can help optimize your e-commerce store’s performance, check out our comprehensive guides on Magento 2 Development Services.

Magento 2 Catalog API Themes

Our network