Home

Awesome

npm version npm downloads changelog License

<p align="center"> <a href="https://v-dropdown-menu.vercel.app" target="_blank"> <img src='/meta/logo.png' width="256" /> </a> </p> <p align="center"> <b>v-dropdown-menu</b> </p> <p align="center"> Customizable dropdown menu for vue πŸŸ©πŸ”½ </p> <p align="center"> <a href="https://v-dropdown-menu.vercel.app" target="_blank"> <img src='/meta/preview.jpg' width="256" /> </a> </p> <p align="center"> <a href="https://github.com/selimdoyranli/v-dropdown-menu" target="__blank"><img alt="GitHub stars" src="https://img.shields.io/github/stars/selimdoyranli/v-dropdown-menu?style=social"></a> </p> <p align="center"> <a href="https://v-dropdown-menu.vercel.app" target="_blank">Website</a> </p> <div align="center"> <sub><b>Sponsorship πŸ’–</b></sub><br> <sub><a href="https://github.com/sponsors/selimdoyranli">GitHub</a></sub><br> <sub><a href="https://buymeacoffee.com/selimdoyranli">Buy me a coffee</a></sub><br> </div>

Features

Getting Started

Try it Online ⚑️

DEMO

Installation

yarn add v-dropdown-menu  # or npm i v-dropdown-menu

Vue3

Global Register

import { createApp } from 'vue'
import App from './App.vue'
import DropdownMenu from 'v-dropdown-menu'
import 'v-dropdown-menu/css'

const app = createApp(App)

app.use(DropdownMenu)
app.mount('#app')

Local Register

<script setup>
import DropdownMenu from 'v-dropdown-menu'
import 'v-dropdown-menu/css'
</script>

Via CDN

<script src="https://unpkg.com/vue@3"></script>
<script src="https://unpkg.com/v-dropdown-menu"></script>
<link rel="stylesheet" href="https://unpkg.com/v-dropdown-menu/dist/vue3/v-dropdown-menu.css">

<script>
  const app = Vue.createApp({})
    
  app.use(DropdownMenu)
  app.mount('#app')
</script>

Vue2

Global Register

import Vue from "vue"
import DropdownMenu from "v-dropdown-menu/vue2"
import 'v-dropdown-menu/vue2/css'

Vue.use(DropdownMenu);

Local Register

import DropdownMenu from "v-dropdown-menu/vue2"
import 'v-dropdown-menu/vue2/css'

export default {
  components: {
    DropdownMenu
  }
}

Via CDN

<script src="https://unpkg.com/vue@2"></script>
<script src="https://unpkg.com/v-dropdown-menu/vue2"></script>
<link rel="stylesheet" href="https://unpkg.com/v-dropdown-menu/dist/vue2/v-dropdown-menu.css">

<script>
new  Vue({
  el: "#app"
});

Vue.use(DropdownMenu);
</script>

Β 

Usage

<dropdown-menu>
  <template #trigger>
    <button>Open Dropdown</button>
  </template>
  
  <template #header> Dropdown Header </template>
  
  <template #body>
    <ul>
      <li v-for="i in 6" :key="i">
        <a href="">Item {{ i }}</a>
      </li>
    </ul>
  </template>
  
  <template #footer> Dropdown Footer </template>
</dropdown-menu>

Props

NameDescriptionTypeOptionsDefault
isOpenShow or hide for dropdownBooleantrue , falsefalse
modeOpen variantStringclick , hoverclick
dropupOpen the menu upwardsBooleantrue , falsefalse
directionMenu container directionStringleft , right , centerleft
closeOnClickOutsidecloses dropdown menu when click outsideBooelantrue , falsetrue
withDropdownCloserIf there is an element in the menu with dropdown-closer attribute, clicking on it closes the menu.Booleantrue , falsefalse
containerZIndexz-index of menu containerString.994
overlaybackground overlay of dropdown menu (only for click mode)Booleantrue , falsetrue
overlayBgColorbackground-color of overlayStringex: rgba(1, 35, 83, 0.8)rgba(0, 0, 0, 0.2)
overlayZIndexz-index of overlayString.992
transitioncustom vue transition for menuString.default

Slots

NameDescription
triggertrigger for dropdown menu
headerheader of menu container (optional)
bodycontent of menu (optional)
footerfooter of menu container (optional)

Events (only for click mode)

@opened="dispatchEvent"
@closed="dispatchEvent"

Development

Vue3

yarn build:vue3 # build for vue3
# Serve

cd dev/vue3

yarn install
yarn serve

Vue2

yarn build:vue2 # build for vue2
# Serve

cd dev/vue2

yarn install
yarn serve

Vue 2&3

yarn build # build for vue2 and vue3

Linter

# run eslint
yarn lint:eslint

# run eslint fix
yarn lint:eslint:fix

# run stylelint
yarn lint:stylelint

# run stylelint fix
yarn lint:stylelint:fix

# run prettier
yarn prettier

Sponsorship

You can sponsor me for the continuity of my projects:

<p align="left"> <a href="https://github.com/sponsors/selimdoyranli"> <img src='https://img.shields.io/github/sponsors/selimdoyranli?style=for-the-badge&label=%E2%99%A5+Be+Sponsor&logo=GitHub'/> </a> </p> <p align="left"> <a href="https://buymeacoffee.com/selimdoyranli"> <img src='https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png'/> </a> </p>

License

MIT License

Copyright (c) selimdoyranli selimdoyranli@gmail.com

<!-- Badges -->