floating-vue icon indicating copy to clipboard operation
floating-vue copied to clipboard

Using floating-vue with Storybook for Vue 3

Open bashovski opened this issue 2 years ago • 3 comments

Hi, I've been trying to use floating-vue with Storybook, but I was unable to import it to one of the storybook pre-generated setup modules .storybook/preview.js.

I've looked into the other solutions on StackOverflow and GH, but those seem outdated as Storybook's vue3 module doesn't export the app anymore, as the simplest solution was to just invoke app.use(FloatingVue) in that case.

Is there something that I've overlooked whilst trying to integrate Storybook? Thanks

bashovski avatar Feb 05 '23 16:02 bashovski

// preview.js
import { app } from '@storybook/vue3';
import FloatingVue from 'floating-vue';
app.vue(FloatingVue)

works for me. "@storybook/vue3": "^6.5.15"

x-ray-s avatar Feb 15 '23 05:02 x-ray-s

Hello, In your component you can simply use it like this :

<script setup lang="ts">
  import 'floating-vue/dist/style.css';
  import { Dropdown } from 'floating-vue';
</script> 
<template>
  <Dropdown ...parameters>
     <template #popper>Content...</template>
  </Dropdown>
</template>

Works with "@storybook/vue3: "^6.5.16"

antoineLZCH avatar Mar 07 '23 15:03 antoineLZCH

For storybook v7^^:

// preview.js
import "floating-vue/dist/style.css";
import { setup } from "@storybook/vue3";
import FloatingVue from "floating-vue";
setup((app) => {
  app.use(FloatingVue);
});

mathiash98 avatar Sep 13 '23 11:09 mathiash98