Home

Awesome

<p align="center"> <img width="350" src="https://github.com/jambonn/vue-popper-lite/assets/10803710/355cd886-dada-4b72-82e3-45537b3d6e3a"> </p>

vue-popper-lite

A popover component based on <a href="https://popper.js.org/docs/v2/performance/#popper-lite">popper-lite</a> for Vue 3 support typescript

Example

Using Vue Popper Lite from Vue SFC

Vue SFC Playground

Using Vue Popper Lite from CDN

Vue from CDN

Install

NPM

npm install vue-popper-lite

Yarn

yarn add vue-popper-lite

PNPM

pnpm add vue-popper-lite

CDN

Recommended: https://unpkg.com/vue-popper-lite, which will reflect the latest version as soon as it is published to npm. You can also browse the source of the npm package at https://unpkg.com/vue-popper-lite/

Usage

Vue environment

<!-- If your content is only a simple string, you can use the content prop -->
<template>
  <v-popper content="This is the Popper content">
    <button slot="reference">
      Reference Element
    </button>
  </v-popper>
</template>

<!-- If your content is more complex, you can use the content slot -->
<template>
  <v-popper>
    <div>This is the Popper content</div>
    <template #reference>
        <button>Trigger element</button>
    </template>
  </v-popper>
</template>

<script>
  import { defineComponent } from "vue";
  import { Popper } from "vue-popper-lite";
  import "vue-popper-lite/style.css";

  export default defineComponent({
    components: {
      'VPopper': Popper,
    },
  });
</script>

Props

NameTypeDefaultDescription
triggerStringhoverOptional value: <br><ul><li>hover - hover to open popper content</li><li>clickToOpen - every click on the popper triggers open, only clicking outside of the popper closes it</li><li>clickToToggle - click on the popper toggles it's visibility</li>
placementStringbottomPreferred placement of the Popper
delay-on-mouse-overNumber10Delay in ms before showing popper during a mouse over
delay-on-mouse-outNumber10Delay in ms before hiding popper during a mouse out
disabledBooleanfalseDisables the Popper. If it was already open, it will be closed.
contentStringnullIf your content is just a simple string, you can pass it as a prop
transitionStringemptyCustom transition class
enter-active-classStringnullCustom transition class enter
leave-active-classStringnullCustom transition class leave
force-showBooleanfalseForce show popper
append-to-bodyBooleanfalseAppend content to body
visible-arrowBooleantrueVisible an arrow on the Popper
arrow-paddingNumber0Stop arrow from reaching the edge of the Popper (in pixels)
enable-flipBooleantruePopper into place, it will not flip dynamically when it runs out of space if this is set to false
offset-kiddingNumber0Offset in pixels along the trigger element
offset-distanceNumber8Offset in pixels away from the trigger element
stop-propagationBooleanfalseStop propagation event click
prevent-defaultBooleanfalsePrevent default event click
strategyStringabsoluteDescribes the positioning strategy to use. If your reference element is in a fixed container, use the fixed strategy
content-classStringemptyClass name for content element

Events

NameDescription
createdCreated popper component
showShow popover
hideHide popover
document-click

Slots

NameDescription
defaultFor the Popper content
referenceFor Trigger the Popper

CSS variables

Popper also uses a list of predefined CSS variables. You can overwrite these variables to suit your needs.

CSS variableExample value
--popper-background#333333
--popper-color#ffffff
--popper-padding8px
--popper-radius4px
--popper-arrow-width8px
--popper-arrow-height8px

Development Setup

# install dependencies
pnpm install

# build dist files
pnpm build

# build dist files and types
pnpm prepublishOnly