themesberg / flowbite

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

I can't setup Flowbite JS on a react project #797

Closed maelfosso closed 5 months ago

maelfosso commented 5 months ago

Hello. I am trying to setup Flowbite on a react project without using flowbite-react but it's not working, the dropdown is not displayed I followed these step

  1. Tailwind CSS was working correctly
  2. I installed flowbite (yarn add flowbite)
  3. I updated tailwind.config.js like this
    /** @type {import('tailwindcss').Config} */
    export default {
    content: [
    "./src/**/*.{js,jsx,ts,tsx}",
    "./node_modules/flowbite/**/*.js",
    ],
    theme: {
    extend: {},
    },
    plugins: [
    require('flowbite/plugin')
    ],
    }
  4. I updated public/index.html by adding before</body> this line , <script src="../node_modules/flowbite/dist/flowbite.min.js"></script>. I also tried with the CDN <script src="https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.2.1/flowbite.min.js"></script>

But the dropdown copied from the document it's not working event the accordion.

How to fix that, please? I DON'T WANT TO USE flowbite-react package.

zoltanszogyenyi commented 5 months ago

Hey @maelfosso,

Even though we do recommend Flowbite React if you want to get the interactive UI components to work, since I think that the CSS and visually everything has rendered correctly, you need to use the initFlowbite() function whenever the component has mounted:

https://flowbite.com/docs/getting-started/javascript/#init-functions

Cheers, Zoltan