-
-
Save jasperf/3e0ea0fffaa7b1cd0fef95461ad01297 to your computer and use it in GitHub Desktop.
Tailwind Navigation Implementation for Wordpress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if (has_nav_menu("main-nav")) {?> | |
<nav class="flex items-center justify-between flex-wrap bg-teal-500 p-6"> | |
<div class="container mx-auto"> | |
<div class="block lg:hidden"> | |
<button class="flex items-center px-3 py-2 border rounded text-teal-200 border-teal-400 hover:text-white hover:border-white"> | |
<svg class="fill-current h-3 w-3" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> | |
<title>Menu</title> | |
<path d="M0 3h20v2H0V3zm0 6h20v2H0V9zm0 6h20v2H0v-2z"></path> | |
</svg> | |
</button> | |
</div> | |
<?php wp_nav_menu( | |
array( | |
"theme_location" => "main-nav", //replace theme location name | |
"container" => "div", | |
"container_class" => "w-full hidden flex-grow lg:flex lg:items-center lg:w-auto", | |
"items_wrap" => '%3$s', | |
"depth" => 1, //todo: add depth dropdown (maybe like https://codepen.io/huphtur/pen/ordMeN) | |
) | |
); | |
?> | |
</div> | |
</nav> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment