I try to assign a CSS class to navigation ( tag) under customer account page.

I found this file customer_account.xml, and I added <argument name="css_class" xsi:type="string">sidebar-navigation__item-link</argument> to the block, as following

                    <block class="Magento\Customer\Block\Account\SortLinkInterface"
                            <argument name="css_class" xsi:type="string">sidebar-navigation__item-link</argument>
                            <argument name="label" xsi:type="string" translate="true">Address Book</argument>
                            <argument name="path" xsi:type="string">customer/addresss</argument>
                            <argument name="sortOrder" xsi:type="number">190</argument>

But this doesn't give any effect on the frontpage. I have cleared the cache.

Did I miss anything?


Try following way:

<block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-orders-link-2">
        <argument name="path" xsi:type="string">sales/order/history</argument>
        <argument name="label" xsi:type="string" translate="true">My Orders 2</argument>
        <argument name="sortOrder" xsi:type="number">230</argument>
        <argument name="attributes" xsi:type="array">
            <item name="class" xsi:type="string">my_custom_link</item>
  • It's working. Thanks. how come I didn't know this. – Magento Learner Mar 7 '19 at 9:10
  • I want to add class to li and not a. Because once the 'current' class is added to li, the child is changed to 'strong' instead of anchor. Please help. – Sejal Shah Sep 11 '19 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.