How do I install a Bootstrap 5 theme with Rails 7
Hello,
I have trouble using a Bootstrap 5 theme (like those we can find on themes.getbootstrap.com, for instance) with a Rails 7 application I'm building. I'm not sure which is the best way to integrate it.
First I intended to install Bootstrap getting rid off nodejs, as explained in this article : https://dev.to/renuo/rails-7-bootstrap-5-and-importmaps-without-nodejs-4g8. It seemed an interesting way of doing it so I wanted to give it a try.
But afterwards, I have a feeling that it make integrating my theme very uneasy. A lot of dependencies like flatpickr or JS features don't work properly.
So at this point, I'm wondering if integrating my theme in a more "classical" maner (as explained there https://eagerworks.com/blog/step-by-step-guide-on-integrating-a-bootstrap-theme-into-rails-7, for instance) wouldn't be a better solution.
Does anyone here is a Bootstrap theme integration warrior and could give some advice, even perhaps a hand?
Off course, I've kept it short but I will gladely share any additional info about all this!
Thanks for reading!
Maëlla
I was updating a Rails 7 app to Rails 8 and considered moving to importmaps until I read too many comments of this nature: "Don’t use importmaps if you need to use JavaScript libraries that include CSS." I suggest doing some more searching before jumping to importmap. I have Bootstrap but not themes.
Since Rails 7 can be set up with different JS/CSS bundling strategies (Importmap, ESBuild, Webpack, Propshaft, or just Sprockets), the exact method depends on what you pickedwhen you created your app.
At this point, your Rails 7 app has Bootstrap 5 Among Us Free and your theme layered on top.
I tried the importmap approach too and ran into similar issues once I started adding themes with lots of JS dependencies. Switching back to the “classic” setup with Node and Webpacker/Vite made things smoother for me, especially when handling plugins like flatpickr. It’s a bit more setup, but less hassle long term. Kind of like crazy cattle 3d —sometimes the simple route looks easier, but the chaos only really settles when you use the right tools!