In this quick article, we will see step by step how to add Bootstrap CSS library in a React App using NPM (Node Package Manager).
Adding Bootstrap, a popular CSS framework, to your React.js project can help you create responsive and visually appealing user interfaces. In this step-by-step guide, we will explore how to add Bootstrap to your React app using NPM (Node Package Manager), the preferred method for managing dependencies in a React project.
Steps to Add Bootstrap in React Using NPM
1. Create a new React app
npx create-react-app my-app
2. Navigate into the app directory
cd my-app
3. Install Bootstrap using NPM
$ npm install bootstrap --save
--save option add an entry in the package.json file
Open the src/index.js file and add the following code:
4. Import Bootstrap CSS in your app
import 'bootstrap/dist/css/bootstrap.min.css';
5. Start the development server
npm start
6. Test Bootstrap styles
function App() {
return (
<div>
<h1 className='text-center'>Hello World!</h1>>
</div>
)
}
export default App
Related Tutorials
- React Hooks - useState and useEffect
- React JS ( React Hooks) + Spring Boot Tutorial
- Create a New React App Step by Step
- Understanding React App Folder Structure
- How to Add Bootstrap to React App
- ReactJS Axios GET, POST, PUT, and DELETE Example Tutorial
- ReactJS Axios Example
- ReactJS Fetch API Example
- React JS CRUD Example Tutorial
- React Router Step-By-Step Tutorial
- React Class Components
- React Functional Components
- React Props
- React State and setState in Class Components
- React useState Hook
- React Conditional Rendering
- How to Add Bootstrap in React JS Using NPM
- How to Create React App using Vite
- Handling Events in React
- How to Consume REST API in React
- React JS Form Validation Example
Comments
Post a Comment
Leave Comment