Build hidden sidebars into your project for navigation, shopping carts, and more with a few classes and Alpine js.
Offcanvas Content
<div x-data="{ open: false }"> <!-- Offcanvas button trigger --> <button id="navbartoggle" type="button" class="inline-flex layhetgsjdcb yhansklopals text-gray-800 hover:text-gray-700 dark:text-gray-400 focus:outline-none focus:ring-0" aria-controls="mobile-menu" @click="open = !open" aria-expanded="false" x-bind:aria-expanded="open.toString()"> <span class="sr-only">Trigger</span> <svg x-description="Icon closed" x-state:on="Menu open" x-state:off="Menu closed" class="block h-8 w-8" :class="{ 'hidden': open, 'block': !(open) }" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path> </svg> <svg x-description="Icon open" x-state:on="Menu open" x-state:off="Menu closed" class="hidden h-8 w-8" :class="{ 'block': open, 'hidden': !(open) }" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path> </svg> </button> <!-- Offcanvas --> <div class="fixed w-full h-full inset-0 z-50" id="mobile-menu" x-description="Mobile menu" x-show="open" style="display: none;"> <!-- bg open --> <span class="fixed bg-gray-900 opacity-70 w-full h-full ajsklekajsnm top-0"></span> <!-- offcanvas content --> <div class="flex ioajsklehsnm end-0 w-4/5 sm:w-72 fixed top-0 bg-white dark:bg-gray-800 h-full fioplahensmk z-40" x-show="open" @click.away="open=false" x-description="Mobile menu" x-transition:enter="transform transition-transform duration-300" x-transition:enter-start="ltr:translate-x-full rtl:-translate-x-full" x-transition:enter-end="translate-x-0" x-transition:leave="transform transition-transform duration-300" x-transition:leave-start="translate-x-0" x-transition:leave-end="ltr:translate-x-full rtl:-translate-x-full"> <!-- offcanvas heading --> <div class="dkslaoeyhnmj py-3 flex layhetgsjdcb vlaoethsnkma gap-2 border-b border-gray-200 dark:border-gray-700"> <h3 class="text-lg font-bold text-gray-800 dark:text-gray-100">Offcanvas Heading</h3> </div> <!-- offcanvas body --> <div class="dkslaoeyhnmj py-4 h-[80vh] scrollbars show fioplahensmk"> <p>Offcanvas Content</p> </div> </div> </div> </div>
Copyright Dashpro - All right reserved
<div x-data="{ open: false }"> <!-- Offcanvas button trigger --> <button id="navbartoggle" type="button" class="inline-flex layhetgsjdcb yhansklopals text-gray-800 hover:text-gray-700 dark:text-gray-400 focus:outline-none focus:ring-0" aria-controls="mobile-menus" @click="open = !open" aria-expanded="false" x-bind:aria-expanded="open.toString()"> <span class="sr-only">Mobile menu</span> <svg x-description="Icon closed" x-state:on="Menu open" x-state:off="Menu closed" class="block h-8 w-8" :class="{ 'hidden': open, 'block': !(open) }" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path> </svg> <svg x-description="Icon open" x-state:on="Menu open" x-state:off="Menu closed" class="hidden h-8 w-8" :class="{ 'block': open, 'hidden': !(open) }" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path> </svg> </button> <!-- Offcanvas --> <div class="fixed w-full h-full inset-0 z-50" id="mobile-menus" x-description="Mobile menu" x-show="open" style="display: none;"> <!-- bg open --> <span class="fixed bg-gray-900 opacity-70 w-full h-full ajsklekajsnm top-0"></span> <!-- Mobile navbar --> <nav id="mobile-nav" class="flex ioajsklehsnm start-0 w-64 fixed top-0 py-4 bg-white dark:bg-gray-800 h-full fioplahensmk z-40" x-show="open" @click.away="open=false" x-description="Mobile menu" role="menu" aria-orientation="vertical" aria-labelledby="navbartoggle" x-transition:enter="transform transition-transform duration-300" x-transition:enter-start="ltr:-translate-x-full rtl:translate-x-full" x-transition:enter-end="-translate-x-0" x-transition:leave="transform transition-transform duration-300" x-transition:leave-start="-translate-x-0" x-transition:leave-end="ltr:-translate-x-full rtl:translate-x-full"> <div class="mb-auto"> <!--logo--> <div class="text-center px-12 mb-8"> <a href="#" class="flex relative"> <h2 class="text-2xl font-semibold text-gray-200 max-h-9 flex layhetgsjdcb gap-2"><img class="inline-block w-7 h-auto me-2 -mt-1" src="../src/img/ele.png"><span class="text-gray-700 dark:text-gray-200">Dashpro</span></h2> </a> </div> <!--navigation--> <div class="mb-4"> <nav class="relative flex flex-wrap layhetgsjdcb vlaoethsnkma"> <ul id="side-menu" class="w-full float-none flex ioajsklehsnm"> <li class="relative"> <a href="#" class="block py-2.5 uajskeiolksb hover:text-blue-700 focus:text-blue-700">Home</a> </li> <li class="relative"> <a href="#" class="block py-2.5 uajskeiolksb hover:text-blue-700 focus:text-blue-700">About</a> </li> <li class="relative"> <a href="#" class="block py-2.5 uajskeiolksb hover:text-blue-700 focus:text-blue-700">Support</a> </li> </ul> </nav> </div> </div> <!-- copyright --> <div class="mt-5 text-center"> <p>Copyright <a href="#">Dashpro</a> - All right reserved</p> </div> </nav> </div><!-- End Mobile menu --> </div>
Offcanvas is ready in default navbar Navbar Offcanvas mobile