Dynamic Filters
June 2025
I really like the idea of transforming simple things into something perfect for the user's eye through animation. This is a great way to create selected multi filters with micro interaction.
Animation
This component was made entirely with Motion. So, I had to create three variants: left, center, and alone.
The alone variant is used when no filter on the side is activated. In this case, the style applied includes a borderRadius of 100% and a marginLeft to ensure that the component isn't "stuck" to other elements.
The left variant is used when a filter is activated on the left side. Here, the component's borderLeftRadius is nullified, and a negative marginLeft is applied to create the “sticky” effect.
Finally, the center variant is positioned between two elements, resulting in a borderRadius of 0.
How to make this work?
This function is responsible for determining the appropriate style, as explained above.
Implementation
The FilterItem component represents each filter button and uses the isStyle prop to determine its animation state.
Managing Filters
Finally, the DynamicFilters function manages the active filter state and applies styles dynamically.