Styling "Current" state with custom code

That’s a neat trick I just found out.

Webflow has a “Current” state to, for example, style the menu item that is opened - you have “about us, work, contact”, you click on “work”, the page open, and the item “work” will be styled differently.

But you can’t that easily style it with custom css… not anymore!

If you type something like:

.menu--item:current { color: blue; }

it won’t work.

What you have to do is select your item in Webflow, where it shows the “Current” state, then just make a change there. Can be invisible like setting background to transparent… whatever, doesn’t matter. But then it will activate a special class created by webflow called “.w–current” that will be applied to the current element (with some custom javascript generated by webflow).

now you can type something like

.menu--item.w--current { color: blue; }

and it will work!
You can use elements like :after or :before, do whatever you want!



Just what I was looking for, thank you Pieter!

Is the current state limited to nav links cause I can’t get it to show on a link block in my page’s body, even though I’ve linked it to a section in the same page


Yes. .w--current is generated as part of Webflow’s navigation elements, so that you can style them differently in the designer.

Other links, like standard link element, or links in rich text, won’t have that .w-current class added even if they’re pointing to the current page.

I see. Thank you very much

If you’re really determined to style your inline links that point to the current page, it’s possible with a small bit of script.

Can you help out please, I was trying the Finsweet CMS Filter Library and got stuck at pagination where the link block was supposed to have the current class. Mine didnt

I actually haven’t used Finsweet’s tools much, but they look well documented. I actually don’t think I could add anything there. But if you share your site link and explain your problem regarding the “current class” I can have a look.

Hi, I was able to get the link to show the current class by clicking on the element in the navigator panel. The embed code still breaks when I add the Finsweet CMS Load Attributes, you can see here. This is my site read-only link