Package Exports
- vue-use-popperjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vue-use-popperjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Vue-use-popperjs
The usePopperjs hook provides an API identical to the ones of createPopper constructor.
Getting Started
Installation
For vue@3:
yarn add vue-use-popperjsFor vue@2 + @vue/composition-api
yarn add vue-use-popperjs @vue/composition-apiUsage
<template>
<div>
<div ref="popcorn" id="popcorn" aria-describedby="tooltip"></div>
<div v-show="visible" ref="tooltip" id="tooltip" role="tooltip">
My tooltip
<div id="arrow" data-popper-arrow></div>
</div>
</div>
</template>
<script>
// For Vue@3
import { ref } from "vue";
// For Vue@2
import { ref } from "@vue/composition-api";
import { usePopperjs } from "vue-use-popperjs";
export default {
setup() {
const popcorn = ref();
const tooltip = ref();
const { instance, visible } = usePopperjs(popcorn, tooltip, {
placement: "top",
modifiers: [
{
name: "offset",
options: {
offset: [0, 8],
},
},
],
});
return {
popcorn,
tooltip,
visible,
};
},
};
</script>API
Parameters
Reference
type: MaybeRef<Element | VirtualElement>
Popper
type: MaybeRef<HTMLElement>
Options
Popperjs Options
See popper.js
Extra Options
| Option | Default | Type | Description |
|---|---|---|---|
| trigger | 'hover' |
'hover' | 'focus' | 'click-to-toggle' | 'click-to-open' | 'manual' |
|
| delay-on-mouseover | 200 |
number |
Delay in ms before showing popper during the mouseover event, only applicable for trigger='hover' |
| delay-on-mouseout | 200 | number | Delay in ms before hiding popper during the mouseout event, only applicable for trigger='hover' |
| force-show | false | boolean | Force show the popper even manually (see the visible of returned value) close it |
Return Type
| Key | Type | Description |
|---|---|---|
| instance | Ref<Instance> |
Popperjs instance |
| visible | Ref<boolean> |
Whether popper is visible, Also allow to manually set this value if trigger='manual' |