overlays
ContextMenu
Display a menu that appears on right click.
Usage
Right click here
<script setup>
const { x, y } = useMouse()
const { y: windowY } = useWindowScroll()
const isOpen = ref(false)
const virtualElement = ref({ getBoundingClientRect: () => ({}) })
function onContextMenu () {
const top = unref(y) - unref(windowY)
const left = unref(x)
virtualElement.value.getBoundingClientRect = () => ({
width: 0,
height: 0,
top,
left
})
isOpen.value = true
}
</script>
<template>
<div @contextmenu.prevent="onContextMenu">
<UContextMenu v-model="isOpen" :virtual-element="virtualElement">
<!-- Content -->
</UContextMenu>
</div>
</template>
Props
virtualElementrequired
Record<string, any>
ui
any
undefined
popper
{}
{}
modelValue
boolean
false
Preset
appConfig.ui.contextMenu
undefined