Through my theme settings I have enabled transparent header, which turns all the contents white when on a background image, and black when scroll or on background colour with no image present.
My hamburger menu has been coded to behave the same using the code below…
In your Shopify admin panel, go to “Online Store” > “Themes” and click on “Actions” > “Edit code” for the theme you’re working on.
In the file list, open the “theme.scss.liquid” file or create a new one if it doesn’t exist.
Add the following CSS code to change the color of the hamburger menu icon based on the background color:
.site-header {
.icon-hamburger {
color: #fff; /* Default color for the hamburger menu icon */
}
/* Change hamburger menu icon color on a dark background */
&.site-header--dark .icon-hamburger {
color: #000;
}
/* Change hamburger menu icon color on a light background */
&.site-header--light .icon-hamburger {
color: #fff;
}
}
In this example, the default color for the hamburger menu icon is set to white. The color is changed to black when the background color is dark (using the “site-header–dark” class) and to white when the background color is light (using the “site-header–light” class).
Save the “theme.scss.liquid” file and preview your store. The hamburger menu icon should now change color based on the background color.