import bootstrap 4 in react
To import Bootstrap 4 in a React project, you can follow these steps:
- Install Bootstrap: Run the following command in your project directory to install Bootstrap using npm:
npm install bootstrap
- Import Bootstrap CSS: Open the file where you want to use Bootstrap styles, usually in the
src
folder. Import the Bootstrap CSS by adding the following line at the top of your file:
import 'bootstrap/dist/css/bootstrap.min.css';
- Import Bootstrap JS (optional): If you want to use Bootstrap's JavaScript components, you can import the Bootstrap JavaScript file. Add the following line at the top of your file:
import 'bootstrap/dist/js/bootstrap.min.js';
That's it! You have successfully imported Bootstrap 4 into your React project. Now you can start using Bootstrap's CSS classes and components in your application.
Note: Make sure you have already set up a React project using tools like Create React App before following these steps.