paint-brush
How to Install Bootstrap 5 on Rails 6 by@jamezjaz
3,533 reads
3,533 reads

How to Install Bootstrap 5 on Rails 6

by James Chigozie OdufuJuly 12th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

This article is for the interest of those who are struggling with installing Bootstrap 5 on their Rails 6 applications. It's also for those who might consider incorporating it on their. applications. The main features are as follows:jQuery Support and improved the JavaScript library to effect this change. New Bootstrap icon library boasts its own open-source. SVG icon library with over 1,300 icons. Improved form controls. Improved grid system. Enhanced documentation with more information - especially when it comes to customization.

Company Mentioned

Mention Thumbnail
featured image - How to Install Bootstrap 5 on Rails 6
James Chigozie Odufu HackerNoon profile picture


Hey Devs!


This article is for the interest of Rails Devs out there who are struggling with installing Bootstrap 5 on their Rails 6 applications. And it's also for the interest of those who might consider incorporating Bootstrap 5 on their Rails 6 applications.

Bootstrap

Bootstrap is a free and open-source CSS Framework that is used for developing responsive web pages. It's easy to use and understand. It's characterized by pretty much pre-defined classes. I'm going to tell us some of the new features of Bootstrap 5. But for me not to defeat the purpose of this article, I'm not going to go into details of these features.


The main features are as follows:


  • jQuery Support

    Bootstrap will not be using the jQuery library anymore. The dev team has improved the JavaScript library to effect this change.
  • CSS Custom Properties IE does not support CSS custom properties, and for this reason, the Bootstrap dev team has dropped Internet Explorer support. So, custom CSS properties (variables) can be used.

  • Documentation Enhanced documentation with more information - especially when it comes to customization.

  • Improved Form Controls In v5, all form controls are customized. These include the radio buttons, checkboxes, files, ranges, and more.

  • New Bootstrap Icon Library Bootstrap now boasts its own open-source SVG icon library with over 1,300 icons. It is custom-made for the framework's components, but you can still work with them on any project.

  • Improved Grid System

  • Bootstrap 5 Adds Utility Libraries

    Installation Instructions

    First, you need to generate your Rails app and then install Bootstrap.

    I'm not going to generate a Rails app here, so go ahead and do that…


    To install Bootstrap 5, follow these steps:
  • On your project directory, pull up the terminal and run the command below:

    $ yarn add bootstrap

    Secondly, let's install popper.js

  • To install popper.js, run

    $ yarn add popper.jsThe next thing is to import Bootstrap.

    To import bootstrap, do the following accordingly:

  • Navigate to app/javascript dir.

  • Create a new folder called stylesheets.

  • Create a new file called application.scss.

  • So you should now have app/javascript/stylesheets/application.scss.

  • Then add:

    @import "bootstrap";

  • Then inside app/javascript/packs/application.js

  • Add these lines one after the other:

    import "bootstrap";

    import "../stylesheets/applications";

  • Check your console and see if you have the error message below: Cannot find module @popperjs/core

    This probably occurs because you added popper manually and thus failed to install popperjs/core as a dependency.


  • To solve this problem, run

    $ yarn add popperjs/core

    You can navigate to node_modules > bootstrap > package.json > dependencies > peerDependencies to verify if popperjs/core is now installed.

    Hopefully, everything should work out now!


    Thank you for your time :)For questions, suggestions, and contributions, reach out to me on… Email:


바카라사이트 바카라사이트 온라인바카라