The documentation lacks clarity on the requirement for both navbar-burger
and navbar-menu
classes to toggle the is-active
property in order to display properly.
Below is a functional solution implemented in Vue, which may be beneficial to others:
<nav class="navbar is-info">
<div class="navbar-brand">
<a role="button" class="navbar-burger burger"
:class="{ 'is-active': isHamburgerOpen }"
@click="openHamburgerMenu"
data-target="navMenu">
<span></span>
<span></span>
<span></span>
</a>
</div>
<div id="navMenu"
class="navbar-menu"
:class="{ 'is-active': isHamburgerOpen }">
<div class="navbar-end">
<!-- menu content -->
</div>
</div>
</nav>
Javascript:
data() {
return {
isHamburgerOpen: false,
}
},
methods : {
openHamburgerMenu() {
this.isHamburgerOpen = !this.isHamburgerOpen;
}
}
No jQuery required. If using vanilla JavaScript, simply access 2 elements by ID and modify their classes through code.