Vue 3 Popper Component

1.5.0 · active · verified Tue Apr 21

vue3-popper is a lightweight and flexible popover component for Vue 3 applications, leveraging PopperJS v2 for accurate positioning. Currently at version 1.5.0, it follows semantic versioning strictly since its 1.0.0 release. The library offers features like configurable placement, offsets, hover triggers, arrows, and manual control of visibility. It is designed to be highly customizable, supporting both simple string content via props and complex HTML structures through slots. Recent updates have focused on improving SSR compatibility (especially with Nuxt 3), refactoring to modern Vue 3 `script setup` syntax, and enhancing type definitions. Its key differentiators include its tight integration with Vue 3's reactive system and its commitment to providing a robust wrapper around the proven PopperJS library, making it a reliable choice for tooltips and popovers in the Vue ecosystem.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates `vue3-popper` with simple string content, complex slot content with hover trigger and arrow, and a manually controlled popover, all within a Vue 3 `<script setup>` context.

<template>
  <section style="display: flex; gap: 20px; justify-content: center; padding: 50px;">
    <Popper content="Hello, I am a simple string Popper!">
      <button>Click for simple content</button>
    </Popper>

    <Popper placement="right" hover arrow :offset-distance="15">
      <button>Hover for complex content</button>
      <template #content>
        <div style="padding: 10px; background-color: #333; color: white; border-radius: 5px;">
          <h4>Interactive Popover</h4>
          <p>This popover supports <b>HTML content</b> and is triggered on hover.</p>
          <button style="background-color: lightblue; border: none; padding: 5px 10px; margin-top: 10px; cursor: pointer;">Action</button>
        </div>
      </template>
    </Popper>

    <Popper :show="showManualPopper" :offset-skid="10">
      <button @click="showManualPopper = !showManualPopper">Toggle Manual Popper</button>
      <template #content>
        <div>Manually controlled popover!</div>
      </template>
    </Popper>
  </section>
</template>

<script setup lang="ts">
import Popper from 'vue3-popper';
import { ref } from 'vue';

const showManualPopper = ref(false);
</script>

<style>
body { font-family: sans-serif; margin: 0; }
button { padding: 10px 15px; border: 1px solid #ccc; background-color: #f0f0f0; cursor: pointer; border-radius: 4px; }
</style>

view raw JSON →