In today’s digital world, having an attractive and user-friendly website is crucial for any business. Shopify, a popular e-commerce platform, provides a range of customizable themes to enhance your online store’s appearance. One such theme is DAWN 10.0.0, which offers the option to add a transparent header. In this tutorial, we will guide you through the process of adding a transparent header to your Shopify store using the DAWN theme.
Benefits of a Transparent Header
A transparent header can elevate the visual appeal of your website by seamlessly blending with the background. It allows your content to take center stage while providing a modern and sleek look. Additionally, a transparent header can enhance user experience by keeping the navigation menu easily accessible and sticky as the user scrolls down the page.
Please follow the code changes below to implement transparent header
Header.liquid File Code Changes
Replace Following
<header class="header header--{{ section.settings.logo_position }} header--mobile-{{ section.settings.mobile_logo_position }} page-width{% if section.settings.menu_type_desktop == 'drawer' %} drawer-menu{% endif %}{% if section.settings.menu != blank %} header--has-menu{% endif %}{% if has_app_block %} header--has-app{% endif %}{% if social_links %} header--has-social{% endif %}{% if shop.customer_accounts_enabled %} header--has-account{% endif %}{% if localization_forms %} header--has-localizations{% endif %}">
With Following
<header id="site-header" class="header header--{{ section.settings.logo_position }} header--mobile-{{ section.settings.mobile_logo_position }} page-width{% if section.settings.menu_type_desktop == 'drawer' %} drawer-menu{% endif %}{% if section.settings.menu != blank %} header--has-menu{% endif %}{% if has_app_block %} header--has-app{% endif %}{% if social_links %} header--has-social{% endif %}{% if shop.customer_accounts_enabled %} header--has-account{% endif %}{% if localization_forms %} header--has-localizations{% endif %} {% if section.settings.transparent_header %}site-header-transparent{% endif %}">
Add following code above {% schema %}
{% if template == 'index' and section.settings.transparent_header %}
{% style %}
.template-index .site-header-transparent .header__icon, .template-index .site-header-transparent .header__menu-item span, .template-index .site-header-transparent .header__menu-item svg, .template-index .site-header-transparent .header__active-menu-item {
color: {{ section.settings.content_color }};
}
.site-header-transparent {
background: transparent;
position: absolute;
border: none;
width: 100%;
left: 50%;
transform: translateX(-50%);
}
.site-header-transition {
margin-top: var(--header-height);
}
{% endstyle %}
<!--- Coded by websensepro.com - youtube.com/c/websensepro --->
<script>
document.addEventListener("DOMContentLoaded", function(event) {
var headerHeight = document.getElementById('site-header').offsetHeight;
document.getElementById('MainContent').style.setProperty('--header-height', '-'+ headerHeight + 'px');
});
window.onscroll = function() {
var header = document.getElementById('site-header');
var main = document.getElementById('MainContent');
var height = document.getElementById('site-header').offsetHeight;
if ( window.pageYOffset > height ) {
header.classList.remove('site-header-transparent');
main.classList.add('site-header-transition');
} else {
header.classList.add('site-header-transparent');
main.classList.remove('site-header-transition');
}
}
document.getElementById("header-menu").addEventListener('click',function () {
var sideMenu = document.getElementById('Details-menu-drawer-container');
var header = document.getElementById('site-header');
var height = document.getElementById('site-header').offsetHeight;
if ( window.pageYOffset < height ) {
if (!sideMenu.classList.contains('menu-opening')) {
header.classList.remove('site-header-transparent');
} else {
header.classList.add('site-header-transparent');
}
}
});
document.getElementById("header-search").addEventListener('click',function () {
var search = document.getElementById('template-index');
var header = document.getElementById('site-header');
var main = document.getElementById('MainContent');
var height = document.getElementById('site-header').offsetHeight;
if ( window.pageYOffset < height ) {
if (search.classList.contains('overflow-hidden')) {
header.classList.remove('site-header-transparent');
main.classList.add('site-header-transition');
} else {
header.classList.add('site-header-transparent');
main.classList.remove('site-header-transition');
}
}
});
</script>
{% endif %}
Add following code after t:sections.all.colors.label
schema code
{ "type": "header", "content": "Transparent Header" }, { "type": "checkbox", "id": "transparent_header", "label": "Enable transparent header", "default": false }, { "type": "color", "id": "content_color", "label": "Change icon & text color" },
Theme.liquid file code changes
Replace Following
<body class="gradient{% if settings.animations_hover_elements != 'none' %} animate--hover-{{ settings.animations_hover_elements }}{% endif %}">
With Following Code
<body {% if template == 'index' %}id="template-index"{% endif %} class="gradient{% if settings.animations_hover_elements != 'none' %} animate--hover-{{ settings.animations_hover_elements }}{% endif %} {% if template == 'index' %}template-index{% endif %}">
If you want help with Shopify Customization, store development, or any other web development help. Send your inquiries here
2 thoughts on “[Dawn 10.0.0] How To Make Transparent Header in Dawn Theme”
Thank You Sir
The best information for this problem. Excellent