themesberg / flowbite

Open-source UI component library and front-end development framework based on Tailwind CSS
https://flowbite.com
MIT License
7.6k stars 716 forks source link

[NuxtJS] Unable to initiate Flowbite, document not found #933

Closed ValentinRgt closed 1 month ago

ValentinRgt commented 1 month ago

Describe the bug I'm currently unable to use Flowbite with NuxtJS 3 (latest), I get an error telling me datepicker document not found... okay, I just want to init Flowbite on my app nothing more. I did my npm install flowbite and just followed this doc: https://flowbite.com/docs/getting-started/quickstart/

Screenshots image

Desktop (please complete the following information):

Code app.vue

<script setup lang="ts">
  import { initFlowbite } from 'flowbite'

  onMounted(() => {
    initFlowbite();
  })
</script>

<template>
  <NuxtPage />
</template>

tailwind.config.js

/** @type {import('tailwindcss').Config} */
export default {
  content: [
    "./components/**/*.{js,vue,ts}",
    "./layouts/**/*.vue",
    "./pages/**/*.vue",
    "./plugins/**/*.{js,ts}",
    "./app.vue",
    "./error.vue",
    "./node_modules/flowbite/**/*.{js,ts}",
  ],
  theme: {
    extend: {},
  },
  plugins: [
    require('@tailwindcss/typography'),
    require('@tailwindcss/forms'),
    require('@tailwindcss/aspect-ratio'),
    require('flowbite/plugin')
  ]
}
zoltanszogyenyi commented 1 month ago

Hey @ValentinRgt,

Please create a wrapper so the client is always available:

https://flowbite.com/docs/getting-started/nuxt-js/#data-attributes

This is also part of the guide.

Cheers, Zoltan