Shopify themes, liquid, logos, and UX
Dawn Theme - How to get drop down menu list on hover instead of click?
Solved! Go to the solution
This is an accepted solution.
Hi @Tadoori_Group,
Go to Online Store, then Theme, and select Edit Code.
Search for header.liquid file Add the provided code at the end of the file.
<script>
let items = document.querySelector(".header__inline-menu").querySelectorAll("details");
let dropdownItems = document.querySelector(".header__submenu");
items.forEach(item => {
item.addEventListener("mouseenter", () => {
item.setAttribute("open", true);
let ulElement = item.querySelector("ul");
if (ulElement !== null) {
ulElement.addEventListener("mouseleave", () => {
item.removeAttribute("open");
});
}
});
item.addEventListener("focus", () => {
item.setAttribute("open", true);
});
item.addEventListener("blur", () => {
item.removeAttribute("open");
});
item.addEventListener("mouseenter", () => {
item.setAttribute("open", "");
});
item.addEventListener("mouseleave", () => {
item.removeAttribute("open");
});
});
if (dropdownItems !== null) {
dropdownItems.addEventListener("mouseleave", () => {
items.forEach(item => {
item.removeAttribute("open");
});
});
}
</script>
This is an accepted solution.
Hi @Tadoori_Group,
Go to Online Store, then Theme, and select Edit Code.
Search for header.liquid file Add the provided code at the end of the file.
<script>
let items = document.querySelector(".header__inline-menu").querySelectorAll("details");
let dropdownItems = document.querySelector(".header__submenu");
items.forEach(item => {
item.addEventListener("mouseenter", () => {
item.setAttribute("open", true);
let ulElement = item.querySelector("ul");
if (ulElement !== null) {
ulElement.addEventListener("mouseleave", () => {
item.removeAttribute("open");
});
}
});
item.addEventListener("focus", () => {
item.setAttribute("open", true);
});
item.addEventListener("blur", () => {
item.removeAttribute("open");
});
item.addEventListener("mouseenter", () => {
item.setAttribute("open", "");
});
item.addEventListener("mouseleave", () => {
item.removeAttribute("open");
});
});
if (dropdownItems !== null) {
dropdownItems.addEventListener("mouseleave", () => {
items.forEach(item => {
item.removeAttribute("open");
});
});
}
</script>
Thanks! It worked!!
However, I want those underlines to be removed. Help with the code please.
When trying to apply it I get this message
What can I do to fix this?
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