I am back with another tutorial.

In this tutorial, Today I will explain How To Add a Class in the body tag while opening the hamburger mobile menu in Hyva Magento2 using TailwindCSS and AlpineJS.

Override the below file in your theme:

vendor/hyva-themes/magento2-default-theme/Magento_Theme/templates/html/header/menu/mobile.phtml

Search @keydown.window.escape=”open=false” and add @click=”addClassToBodyTag()” code after that line.

Replace the below code:

<script>
    'use strict';

    const initMenuMobile<?= $escaper->escapeHtml($uniqueId) ?> = () => {
        return {
            mobilePanelActiveId: null,
            open: false,
            setActiveMenu(menuNode) {
                Array.from(menuNode.querySelectorAll('a')).filter(link => {
                    return link.href === window.location.href.split('?')[0];
                }).map(item => {
                    item.classList.add('underline');
                    item.closest('div.level-0') &&
                    item.closest('div.level-0').querySelector('a.level-0').classList.add('underline');
                });
            }
        }
    }
</script>

With

<script>
    'use strict';

    const initMenuMobile<?= $escaper->escapeHtml($uniqueId) ?> = () => {
        return {
            mobilePanelActiveId: null,
            open: false,
            setActiveMenu(menuNode) {
                Array.from(menuNode.querySelectorAll('a')).filter(link => {
                    return link.href === window.location.href.split('?')[0];
                }).map(item => {
                    item.classList.add('underline');
                    item.closest('div.level-0') &&
                    item.closest('div.level-0').querySelector('a.level-0').classList.add('underline');
                });
            },
            addClassToBodyTag() {
                document.body.classList.toggle("nav-open");
            }
        }
    }
</script>

Now you can see a nav-open class in the body tag when you will open a menu in the Mobile view.

I hope this blog is easy to understand about How To Add a Class in the body tag while opening the hamburger mobile menu in Hyva Magento2 using TailwindCSS and AlpineJS. I hope you have got the above coding concepts. Now you can easily implement the above functionality in your Hyva project. In case, I missed anything or need to add some information, always feel free to leave a comment in this blog, I’ll get back with proper solution.

Keep liking and sharing !!

More will be coming soon… 🙂


I am back with another tutorial.

In this tutorial, Today I will explain How To Add a Modal pop-up in Hyva Magento2 using TailwindCSS and AlpineJS.

You just add the below code in any PHTML file or CMS Page/Block when you need to add Modal pop-up.

<div class="container mx-auto p-6 text-center">
    <div class="mt-6" x-data="{ open: false }">
        <button class="bg-blue-500 text-white px-4 py-2 rounded no-outline focus:shadow-outline select-none" @click="open = true">Open Dropdown</button>
        <div class="absolute top-0 left-0 w-full h-full flex items-center justify-center z-10" style="background-color: rgba(0,0,0,.5);" x-show="open">
            <div class="text-left bg-white h-auto p-4 md:max-w-xl md:p-6 lg:p-8 shadow-xl rounded mx-2 md:mx-0" @click.away="open = false">
                <h2 class="text-2xl">Modal title</h2>
                <ul class="list-decimal m-4">
                    <li>Lorem Ipsum is simply dummy text of the printing and typesetting industry</li>
                    <li>Lorem Ipsum is simply dummy text of the printing and typesetting industry</li>
                    <li>Lorem Ipsum is simply dummy text of the printing and typesetting industry</li>
                    <li>Lorem Ipsum is simply dummy text of the printing and typesetting industry</li>
                    <li>Lorem Ipsum is simply dummy text of the printing and typesetting industry</li>
                </ul>
                <div class="flex justify-center mt-8">
                    <button class="bg-gray-700 text-white px-4 py-2 rounded no-outline focus:shadow-outline select-none" @click="open = false">Close</button>
                </div>
            </div>
        </div>
    </div>
</div>

See example how it’s work:

I hope this blog is easy to understand about How to add Modal pop-up in Hyva Magento2 using TailwindCSS and AlpineJS. I hope you have got the above coding concepts. Now you can easily implement the above functionality in your Hyva project. In case, I missed anything or need to add some information, always feel free to leave a comment in this blog, I’ll get back with proper solution.

Keep liking and sharing !!

More will be coming soon… 🙂


I am back with another tutorial.

Password field by default doesn’t show any visible text other than the symbol. Because It can be protected from hacking. But most of the users need a visible password. Hence, you can give them a password visibility option with jQuery. Therefore, In this tutorial, you will know How To Show and Hide Password Field Text in Hyva Magento2 using TailwindCSS and AlpineJS.

You just add below code in your any PHTML file when you need to show and hide password field text.

<div class="password required" x-data="{ show: true }">
    <div class="flex items-center">
        <input name="login[password]"
            class="form-input w-full" 
            :type="show ? 'password' : 'text'"
            <?php if ($block->isAutocompleteDisabled()): ?>
                autocomplete="off"
            <?php endif; ?>
                id="pass"
                placeholder="<?= $escaper->escapeHtmlAttr(__('Password')) ?>"
                title="<?= $escaper->escapeHtmlAttr(__('Password')) ?>"/>
        <div class="cursor-pointer p-3 w-24 border ml-1 text-center"
            @click="show=! show" x-text=" show ? 'Show' : 'Hide' ">                            
        </div>                
    </div>
</div>

See example how it’s work:

I hope this blog is easy to understand about How To Show and Hide Password Field Text in Hyva Magento2 using TailwindCSS and AlpineJS. I hope you have got the above coding concepts. Now you can easily implement the above functionality in your Hyva project. In case, I missed anything or need to add some information, always feel free to leave a comment in this blog, I’ll get back with proper solution.

Keep liking and sharing !!

More will be coming soon… 🙂


In this tutorial, Today I will explain How To Add Quantity Increment And Decrement Button in Hyva Magento2 on Shopping Cart Page using TailwindCSS and AlpineJS.

In hyva theme you need to just copy below code and replace in app/design/frontend/Vendor/YourTheme/Magento_Checkout/templates/cart/items.phtml file with QTY code.

<div class="block text-left flex items-center">                                
    <div class="flex">
        <button :disabled="item.quantity <= 1" x-on:click="item.quantity--;" x-on:click.debounce.1000="mutateItemQty(item.id, item.quantity)" class="border rounded w-11 h-9 mr-1" disabled="disabled">
            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 m-auto" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18 12H6" />
            </svg>
        </button>
        <input type="text" :name="'qty' + item.id" x-model.number="item.quantity" :value="item.quantity" class="form-input w-11 h-9 text-center rounded p-0 mr-1" max="99" pattern="[0-9]{0,4}" min="1" x-on:change.debounce.1000="mutateItemQty(item.id, $event.target.value);" name="qty30884">
        <button x-on:click="item.quantity++;" x-on:click.debounce.1000="mutateItemQty(item.id, item.quantity)" class="border rounded w-11 h-9 mr-1">
            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 m-auto" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
            </svg>
        </button>
    </div>
</div>

See example how it’s Looks:

I hope this blog is easy to understand about How To Add Quantity Increment And Decrement Button in Hyva Magento2 on Shopping Cart Page using TailwindCSS and AlpineJS. In case, I missed anything or need to add some information, always feel free to leave a comment in this blog, I’ll get back with proper solution.

Keep liking and sharing !!

More will be coming soon… 🙂


In this tutorial, Today I will explain How to add custom font in Hyva Magento2.

Download fonts from Google https://fonts.google.com/specimen/Roboto

Create fonts folder under app/design/frontend/Vendor/theme/web/fonts add woff2 fonts in it.

Open typography.css file from your theme and add below code in it app/design/frontend/Vendor/theme/web/tailwind/components/typography.css

@font-face {
    font-family: 'Roboto';
    src: url('../fonts/roboto-bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Roboto';
    src: url('../fonts/roboto-medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

Currently, I have added only two font weights you can add more font weight and italic using above code.

Create your own class using below CSS for Robot fonts. You can use .roboto class in HTML and CSS where you need Roboto fonts.

.roboto {
    font-family: 'Roboto', "Helvetica Neue", Arial, sans-serif;
}

I hope this blog is easy to understand about How to add custom font in Hyva Magento2. In case, I missed anything or need to add some information, always feel free to leave a comment in this blog, I’ll get back with proper solution.

Keep liking and sharing !!

More will be coming soon… 🙂