yaminncco / vue-sidebar-menu

A Vue.js Sidebar Menu Component
MIT License
654 stars 193 forks source link

how to move a menu item to the bottom #234

Closed anubisg1 closed 2 years ago

anubisg1 commented 2 years ago

How can i move an entry at the bottom of the menu ? for example i'd like to move the "settings" menu entry at the bottom of the screen

yaminncco commented 2 years ago

We can achieve this with flex and margin-top auto. First add css flex to the menu

.v-sidebar-menu .vsm--menu {
  display: flex;
  flex-direction: column;
  height: 100%;
}

Then create a component that push everything that comes after it to the bottom

import { h, markRaw } from 'vue'
const pushToBottom = markRaw({
  render: () => h('div'),
  mounted () {
    const itemEl = this.$el.parentElement
    itemEl.style.marginTop = 'auto'
  }
})

menu: [
  ...
  {
    component: pushToBottom
  },
  {
    title: 'Settings'
  }
]
anubisg1 commented 2 years ago

oh thanks a lot! let me try that out!

anubisg1 commented 2 years ago

it works perfectly! thank you

image