Score:0

Can I add classes to individual menu links?

eg flag

I am using the main menu /admin/structure/menu/manage/main

There are a couple of links that I want to display only in mobile devices, and then also another couple of links that I want to display only in laptop devices. Can I do this without needing two separate menus? I guess one way would be to attach a css class to the relevant links but looking at /admin/structure/menu/item/1/edit there is no option to add classes to a menu link in the menu UI.

I don't want to use CSS nth-child because if in future the menu is edited / reordered then any nth-child rules will get messed up.

So can anyone tell me how to add an option to add classes to individual menu links in the menu UI - and / or some alternative route.

Score:3
cn flag

The Menu Link Attributes contrib module adds the option to assign each menu link a class in the admin UI.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.