Skip to main content
Category:

How to add custom classes for menu links in Drupal 8 & 9

 

Example How to add custom classes for menu links in Drupal 8 & 9:

 

Method 1:

{{ link(item.title, item.url.setOption('attributes', {'class' : 'main-nav__link'})) }}

 

Method 2:

{{ link(item.title, item.url, { 'class':['main-nav__link']}) }}

Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts

Search

Page Facebook