A Vue.js popover component based on PopperJS

Overview

vue3-popper

A popover component for Vue 3

Documentation

Check out the documentation

Install

NPM

npm install vue3-popper

Yarn

yarn add vue3-popper

Usage

Vue environment

<!-- If your content is only a simple string, you can use the content prop: -->
<template>
  <Popper content="This is the Popper content">
    <button>Trigger element</button>
  </Popper>
</template>

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

<script>
  import { defineComponent } from "vue";
  import Popper from "vue3-popper";

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

Props

Name Default Description
placement bottom Preferred placement of the Popper
disableClickAway false Disables automatically closing the Popper when the user clicks away from it
offsetSkid 0 Offset in pixels along the trigger element
offsetDistance 12 Offset in pixels away from the trigger element
hover false Trigger the Popper on hover
arrow false Display an arrow on the Popper
arrowPadding 0 Stop arrow from reaching the edge of the Popper (in pixels)
disabled false Disables the Popper. If it was already open, it will be closed.
openDelay 0 Open the Popper after a delay (ms)
closeDelay 0 Close the Popper after a delay (ms)
interactive true If the Popper should be interactive, it will close when clicked/hovered if false
content null If your content is just a simple string, you can pass it as a prop
show null Control the Popper manually, other events (click, hover) are ignored if this is set to true/false
zIndex 9999 The z-index of the Popper

Events

Name Description
open:popper When the Popper is opened
close:popper When the Popper is hidden

Slots

Name Description
content For the Popper content

Slot props

The content slot gives you access to useful variables and functions.

Name Type Description
close function A function to close the Popper
isOpen boolean The open state of the Popper

CSS variables

Popper only comes with some barebones styling by default, but it also uses a list of predefined CSS variables. You can overwrite these variables to suit your needs.

CSS variable Example value
--popper-theme-background-color #ffffff
--popper-theme-background-color-hover #ffffff
--popper-theme-text-color inherit
--popper-theme-border-width 1px
--popper-theme-border-style solid
--popper-theme-border-color #eeeeee
--popper-theme-border-radius 6px
--popper-theme-padding 16px
--popper-theme-box-shadow 0 6px 30px -6px rgba(0, 0, 0, 0.25)
Comments
  • Rendered content

    Rendered content

    Hi! First, thank you for your great lib!

    When we render a lot of popper, the browser will drastically slow down (due to popper.js) Do you know how to render the popper on the fly ? Or a way to render the content only when the selector is hovered ?

    Thx you!

    enhancement 
    opened by AubSs 6
  • let content know if open

    let content know if open

    hey great work! i'm just switching to vue 3 and used vue-tippy before

    what i'm struggling with:

    situation 1: often i load more content from server when tippy is shown. i COULD solve this with the show-event but its really dirty ^^ it would be nice if i nut just could "import" the close-function, but also isOpen example: <template #content="{close, isOpen}">

    if this would be possible i could conditionally decide what to render and trigger what to fetch for the server

    situation 2: is it possible to use 1 popper for multiple elements? in vue-tippy i could use :to="element" to change the element where the popper was bound to why: in a table with 100 rows and 3 columns where every column has a popper, this would be 300 poppers nice would be to have 3 popper, one for each column and when i hover over a table-cell i will change a variable so the content within the popper can update is that possible?

    opened by mech01nc01 6
  • Crashes after upgrading vue3-popper to anything above 1.2.1

    Crashes after upgrading vue3-popper to anything above 1.2.1

    Hey, I've been using your popper component for a long time now, but I tried upgrading to the newest version today in hopes to resolve an issue I'm having, but I am getting a crash anytime I upgrade to a version higher than 1.2.1. I was on 1.1.0 previously. I did a few installs one version at a time and found that everything runs ok for 1.1.0, 1.2.0 and 1.2.1. But anything higher than that and I get the following runtime crash...

    I don't see any open issues related to this, so I wanted to get your input, if you have the time. Anything that immediately comes to mind that I might be missing? Thanks!

    Screenshot 2021-12-16 03 29 15

    opened by thebreadlord 4
  • Upgrading to Vue 3.2.x breaks the Popper component

    Upgrading to Vue 3.2.x breaks the Popper component

    Hi, great work on the library I am enjoying it! I was using Vue-3-popper v1.2.1 and Vue 3.1.2 and it works fine, but when I try to upgrade Vue to 3.2.x and Vue-3-popper to 1.3.0 I get strange runtime errors that I cannot explain. Hoping you can help me fix it.

    These are the 2 errors I see, which prevents my entire view from loading.

    chrome_DwHM3UmnKa chrome_FJRmWgK4gv

    I've followed the documentation and made my own wrapper component for the Popper component. I use it like this in my view: <PopoverIcon class="d-inline-flex" :content="$tc('contractOverview.table.contractExpirationWarning', { count: item.data.remainingDays})"><i class="pi pi-exclamation-circle" /></PopoverIcon> However, when I try to upgrade to Vue 3.2 even the sample component does not work for me. I think it could be related to the slot property, but seeing as even the example does not work I don't know how to fix it. Any idea what could be causing this?

    opened by Flippeey 4
  • Appears to Apply Styling to the Attached Element

    Appears to Apply Styling to the Attached Element

    Apologies if I'm getting this wrong, but it appears to apply styling to the element the popper is attached to:

    element.style {
        border: 12px solid transparent;
        margin: -12px;
        --23121010: 9999;
    }
    

    I would suggest styling of the attached element is removed and left to the user.

    opened by B1ue-W01f 4
  • Keeping popper open while hovering over it

    Keeping popper open while hovering over it

    Hey, I love what you've got so far! I do have a specific need though for our client and I was going to see if you could help me out? Basically, when using the "hover" option for the Popper, we would like to keep the popper open as long as the user is hovering over either the trigger element or the popper itself. We are using this to provide a user some options (with buttons for confirming/rejecting and such) when hovering over certain elements. Is there any way we can make that happen? I'd appreciate it, and thanks for your time!

    enhancement 
    opened by thebreadlord 4
  • Render popper element based on condition

    Render popper element based on condition

    Hi! First of all; great job writing this very easy to use popper component!

    I would like to request a feature regarding conditional rendering. I have the following scenario:

    <template>
      <Popper arrow hover>
        <button> hover me! </button>
        <template #content v-if="condition ">
          Show popper only when condition is met
        </template>
      </Popper>
    </template>
    

    Shown result

    I get an empty popper element on hover, due to the fact that I conditionally render the content template.

    Expected result

    I can pass a show prop to the Popper component, or the popperNode checks if the content slot is defined: https://github.com/valgeirb/vue3-popper/blob/main/src/component/Popper.vue#L18

    I would like the popper element to not be rendered / shown when I explicitly say so. It can be visible by default (implicitly) of course.

    bug enhancement 
    opened by bnachtweh 4
  • [Feature Request] Close Popper when you hover over it with mouse

    [Feature Request] Close Popper when you hover over it with mouse

    Right now there is no way to tell Popper to close when you hover over it with mouse. Sometimes it is useful when there are buttons behind popper and you can't click on them because popper is in front of them.

    This is an issue only when you set the mode to hover=true

    It would be nice to have an option to hide it on hover like this

    <Popper :hover="true" :closeOnHover="true">
        ....
    </Popper>
    
    opened by martinszeltins 3
  • Prevent a Popper with a delay from closing if the cursor left and then returned before it started closing

    Prevent a Popper with a delay from closing if the cursor left and then returned before it started closing

    If you have a Popper with a closeDelay and hover props and you

    1. Hover over the trigger
    2. Leave the trigger
    3. Hover again before it closes

    It still closes. It should stay open.

    bug 
    opened by valgeirb 3
  • Don't use directives

    Don't use directives

    You should remove the usage of directives and use composable for click away... for example: https://vueuse.org/core/onClickOutside/

    They aren't working in SSR apps, and require custom transformers in build tools.

    Vue documentation says:

    We recommend to prefer using components as the abstraction mechanism instead of directives.

    opened by xvaara 2
  • Is it possible to prevent popper from flipping and lock it's placement?

    Is it possible to prevent popper from flipping and lock it's placement?

    Even though I have set the placement to "top" it still flips to bottom when it want to. Is there a way to force placement to always be top?

    <Popper :hover="true" arrow placement="top" ...>
        ....
    </Popper>
    
    opened by martinszeltins 2
  • Feature/add strategy prop

    Feature/add strategy prop

    Related request https://github.com/valgeirb/vue3-popper/issues/74

    • Tested in dev mode, works like a charm ✅
    • Prop is properly reactive ✅

    would be glad to see it merged soon and shipped in a release

    opened by qnp 0
  • When ı switched pages to quickly popper wasn't disconnect

    When ı switched pages to quickly popper wasn't disconnect

    **When ı switched pages to quickly popper wasn't disconnect ** Popper can't reach "disconnect" function

    error in popper.esm.js:129:34 line

    Please help me

    opened by Meeyzt 2
  • Offset overlap prevents from showing the tooltip on hover

    Offset overlap prevents from showing the tooltip on hover

    Description of the bug vue3-popper: v1.5.0 Applying offset overlaps with nearby items. I'm trying to move the tooltip to the right side of the column and if I have the tooltip item below with the same offset it won't let me hover over and open the popup.

    Reproduction link Place 2 tooltip items nearby and apply offsetDistance="100".

    Expected behavior Have the ability to specify which side to offset (offsetLeft, offsetRight, offsetTop, offsetBottom)

    Screenshots Screenshot 2022-11-21 at 8 09 12 PM

    opened by michaelscraft 1
  • Landing page / Docs:

    Landing page / Docs: "Guide" hyperlink goes to page with 404 message

    Description of the bug Clicking on "Guide" in the top right corner removes the button demo and shows a 404 message.

    To Reproduce Steps to reproduce the behavior:

    1. Go to https://valgeirb.github.io/vue3-popper/
    2. Click on 'Guide' (top right corner)
    3. New URL is https://valgeirb.github.io/vue3-popper/guide/what-is-vue-popper.html
    4. It's the same as the landing page with a 404 message instead of the button demo

    ... assuming it's meant to link to this: https://valgeirb.github.io/vue3-popper/guide/what-is-vue-3-popper.html

    Expected behavior Being taken to a new page with a guide

    Screenshots image

    opened by eirikove 0
  • preventOverflow missing

    preventOverflow missing

    The old version vue popper had the ability to turn off preventOverflow so that a container would not cut off the modal. This version does not have that ability and my modals are getting cut off by a container that has an overflow set.

    opened by craiggeil 0
Releases(v1.5.0)
📓 The UI component explorer. Develop, document, & test React, Vue, Angular, Web Components, Ember, Svelte & more!

Build bulletproof UI components faster Storybook is a development environment for UI components. It allows you to browse a component library, view the

Storybook 75.8k Jan 4, 2023
Mobile app development framework and SDK using HTML5 and JavaScript. Create beautiful and performant cross-platform mobile apps. Based on Web Components, and provides bindings for Angular 1, 2, React and Vue.js.

Onsen UI - Cross-Platform Hybrid App and PWA Framework Onsen UI is an open source framework that makes it easy to create native-feeling Progressive We

null 8.7k Jan 8, 2023
A small component based app library composing user interfaces and apps.

See https://vibejs.com for ongoing documentation and info. VibeJS A small component based JavaScript library to build user interfaces and apps. If you

Bret 20 Nov 16, 2022
TV Show App is an application that allows to searh tv shows based on user input. Each tv show is displayed in a Bulma Card component and when clicked, heads you to the official tv show site

TV SHOW APP TV Show App is an application that allows to search tv shows based on user input. Each tv show is displayed in a Bulma* Card component and

HENDEL SAMY 1 Dec 19, 2021
Collection of Animated 60 FPS TabBar Component's based on React Navigation.

React Navigation TabBar Collection Collection of Animated 60 FPS TabBar Components based on React Navigation. Features 60 FPS Animation Beautiful TabB

Mikalyh 22 Dec 9, 2022
A component library based on Material Design 3 & Web Components

material-web-entity Material Web Entity A component library based on Material Design & Web Components Go to link to see what components this library s

HugePancake 5 Jun 3, 2022
A labeler component that Lays out text and overlays textual decorations like labels, predictions, and relations based on given data and handles user interactions on tokens.

react-text-annotator react-text-annotator is a labeler component that: Lays out text and overlays textual decorations like labels, predictions, and re

Microsoft 25 Dec 11, 2022
JavaScript data grid with a spreadsheet look & feel. Works for React, Angular, and Vue. Supported by the Handsontable team ⚡

Handsontable is a JavaScript component that combines data grid features with spreadsheet-like UX. It provides data binding, data validation, filtering

Handsontable 17.4k Jan 1, 2023
The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript.

Module SonarCloud Status ag-grid-community ag-grid-enterprise AG Grid AG Grid is a fully-featured and highly customizable JavaScript data grid. It del

AG Grid 9.5k Dec 30, 2022
Material-UI is a simple and customizable component library to build faster, beautiful, and more accessible React applications. Follow your own design system, or start with Material Design.

Material-UI Quickly build beautiful React apps. Material-UI is a simple and customizable component library to build faster, beautiful, and more access

Material-UI 83.6k Dec 30, 2022
The Select Component for React.js

React-Select The Select control for React. Initially built for use in KeystoneJS. See react-select.com for live demos and comprehensive docs. React Se

Jed Watson 25.6k Jan 3, 2023
:hourglass_flowing_sand: A higher order component for loading components with promises.

A higher order component for loading components with dynamic imports. Install yarn add react-loadable Example import Loadable from 'react-loadable'; i

Jamie Kyle 16.5k Jan 3, 2023
A Higher Order Component using react-redux to keep form state in a Redux store

redux-form You build great forms, but do you know HOW users use your forms? Find out with Form Nerd! Professional analytics from the creator of Redux

Redux Form 12.6k Jan 3, 2023
⚪ SVG-Powered component to easily create skeleton loadings.

SVG-Powered component to easily create placeholder loadings (like Facebook's cards loading). Features ⚙️ Customizable: Feel free to change the colors,

Danilo Woznica 12.7k Jan 4, 2023
Isolated React component development environment with a living style guide

Isolated React component development environment with a living style guide React Styleguidist is a component development environment with hot reloaded

Styleguidist 10.6k Jan 5, 2023
Markdown component for React

react-markdown Markdown component for React using remark. Learn markdown here and check out the demo here. Install npm: npm install react-markdown Why

remark 9.7k Jan 4, 2023
React draggable component

React-Draggable A simple component for making elements draggable. <Draggable> <div>I can now be moved around!</div> </Draggable> Demo Changelog Vers

RGL 8.1k Jan 4, 2023
A React Component library implementing the Base design language

Base Web React Components Base is a design system comprised of modern, responsive, living components. Base Web is the React implementation of Base. Us

Uber Open Source 8.1k Dec 29, 2022
Accessible modal dialog component for React

react-modal Accessible modal dialog component for React.JS Table of Contents Installation API documentation Examples Demos Installation To install, yo

React Community 7.1k Jan 1, 2023