Shopify themes, liquid, logos, and UX
Hi All,
I have the following code in Impulse theme within toolbar.liquid where I have toolbar_menu items and based on click I want to attach an active class. I have been trying to use link.current property to keep track but no class gets added upon inspection. Below is the code snippet within toolbar.liquid:
{% if section.settings.toolbar_menu != blank %}
<div class="toolbar__item toolbar__item--menu">
<ul class="inline-list toolbar__menu">
{% for link in toolbar_menu.links %}
<li>
<a href="{{ link.url }}" {% if link.current %}aria-current="page" class="active" style="color:yellow;"{% endif %}>{{ link.title }}</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
@rjtbansal wrote:Hi All,
I have the following code in Impulse theme within toolbar.liquid where I have toolbar_menu items and based on click I want to attach an active class. I have been trying to use link.current property to keep track but no class gets added upon inspection. Below is the code snippet within toolbar.liquid:
{% if section.settings.toolbar_menu != blank %}
<div class="toolbar__item toolbar__item--menu">
<ul class="inline-list toolbar__menu">
{% for link in toolbar_menu.links %}
<li>
<a href="{{ link.url }}" {% if link.current %}aria-current="page" class="active" style="color:yellow;"{% endif %}>{{ link.title }}</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
<div class="">
<ul class="menu">
{% for link in linklists['main-menu'].links %}
<li>
<a href="{{ link.url }}" {% if link.current == true %}class="active" {% endif %}>{{ link.title }}</a>
</li>
{% endfor %}
</ul>
</div>
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025