creativetimofficial / material-tailwind

@material-tailwind is an easy-to-use components library for Tailwind CSS and Material Design.
https://material-tailwind.com/
MIT License
3.51k stars 306 forks source link

Compatible with HTMX? #697

Open anentropic opened 3 weeks ago

anentropic commented 3 weeks ago

I'm trying to evaluate whether this library will work with HTMX.

So i.e. with one of the non-SPA framework integration options, such as https://www.material-tailwind.com/docs/html/guide/django

The docs show that in this case you should add the script tag at the bottom of the page.

Looking at the contents of the script (e.g. for Ripple effect) it seems that this is a run-once initialisation, via a self-invoking anonymous function.

I haven't tried it, but seems like this is not going to work with HTMX since any components loaded by subsequent request won't be initialised, and there's no way to get a reference to the initialiser to call it manually.

OTOH the React integration docs recommend exactly the same thing: https://www.material-tailwind.com/docs/html/guide/react-vite#ripple-effect so perhaps I am missing something about how this works?

Or maybe those docs are obsolete? I see elsewhere there are different docs https://www.material-tailwind.com/docs/react/guide/vite which show installing dedicated React components npm i @material-tailwind/react and not adding the script tag, seems like that way is more likely to work for an SPA.

My questions are: