A discussion about creating a custom widget for a hamburger menu in a Discourse theme. Juraj_Štefánik asks how to add a sub-menu that appears on hover or click. keegan responds by suggesting a custom widget, providing an example of how to return a widget using api.decorateWidget and create a custom widget using createWidget.
Finally, keegan answers Juraj_Štefánik’s follow-up question on how to add target="_blank" to an anchor tag, providing an example of how to add it to the attributes object.
Hello, if I want to add an ul list to the hamburger menu with from the submenus that I see either on a click or on a hover mouse, should I do it this way or know something more efficient?
I can add individual items to the hamburger menu via a component, but I need to supply sub items there that will be displayed on the hover
What you could do is return your own custom widget to api.decorateWidget, which will give you a lot more control in terms of applying attributes, state, actions, etc.