0.1.5 • Published 4 months ago

vue-popper-lite v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

vue-popper-lite

A popover component based on popper-lite 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: hover - hover to open popper contentclickToOpen - every click on the popper triggers open, only clicking outside of the popper closes itclickToToggle - click on the popper toggles it's visibility
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
0.1.5

4 months ago

0.1.4

9 months ago

0.1.3

9 months ago

0.1.2

9 months ago

0.1.1

9 months ago

0.1.0

9 months ago