Vue Burger Menu

2.0.5 · maintenance · verified Sun Apr 19

Vue Burger Menu is a Vue.js component that provides a collection of off-canvas sidebar menu effects and styles. It leverages CSS transitions and SVG path animations to deliver various hamburger menu experiences, such as sliding, scaling, rotating, and revealing effects. The library is currently at version 2.0.5, with its latest release six years ago, indicating a maintenance-focused cadence rather than active feature development. Key differentiators include its ready-to-use animations, customizable properties like width and position, and event hooks for managing menu state. It abstracts away complex CSS and SVG animations into easy-to-use Vue components, supporting Vue 2 and likely Vue 3 (though a separate `vue3-burger-menu` package also exists). The package aims to save screen space on mobile devices by hiding navigation until a user action reveals it.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates installation, basic usage of the `Slide` animation, registering the component, passing menu items as slots, and controlling the menu's open state programmatically with event handlers.

npm install vue-burger-menu --save

// In a Vue component (e.g., App.vue)
<template>
  <div id="app">
    <Slide :isOpen="isMenuOpen" @openMenu="handleOpenMenu" @closeMenu="handleCloseMenu">
      <a id="home" href="#"><span>Home</span></a>
      <a id="about" href="#"><span>About</span></a>
      <a id="contact" href="#"><span>Contact</span></a>
    </Slide>
    <main id="page-wrap">
      <h1>My Application Content</h1>
      <p>Click the burger icon to open the menu.</p>
      <button @click="toggleMenu">Toggle Menu from App</button>
    </main>
  </div>
</template>

<script>
import { Slide } from 'vue-burger-menu';

export default {
  name: 'App',
  components: {
    Slide
  },
  data() {
    return {
      isMenuOpen: false
    };
  },
  methods: {
    handleOpenMenu() {
      this.isMenuOpen = true;
      console.log('Menu opened');
    },
    handleCloseMenu() {
      this.isMenuOpen = false;
      console.log('Menu closed');
    },
    toggleMenu() {
      this.isMenuOpen = !this.isMenuOpen;
    }
  }
};
</script>

<style>
body { margin: 0; font-family: sans-serif; }
#app { /* Required for some animations like Push/PushRotate */ }
#page-wrap { padding: 20px; }
</style>

view raw JSON →