How to Install Bootstrap 5 in Angular 14?
Hi Dev,
In this example, I will show you angular 14 add bootstrap. this example will help you angular 14 install bootstrap 5. you'll learn install bootstrap in angular 14. you can understand a concept of install bootstrap 5 in angular 14.
As we know Bootstrap is the world’s most popular framework for building responsive, and mobile-first sites. bootstrap provide several class for making responsive website for your mobile. So if you want to use bootstrap with angular 14 than i will help you very simple way.
I have a two install bootstrap and use it with your angular 14 project. i will give you both way example bellow.
You can easily create your angular app using bellow command:
ng new my-new-app
Example 1:
In this solution, you need to just install bootstrap on your angular 14 and import css file to style.css file. this is only for css importing. so you can run command bellow:
npm install bootstrap --save
Ok, now you need to import your bootstrap css on style.css file as like bellow:
src/style.css
@import "~bootstrap/dist/css/bootstrap.css";
Now you can use bootstrap class in your angular 14 app. It will works.
Example 2:
In this solution, we will also install bootstrap with jquery and popper js. so that way you can also import bootstrap css and bootstrap js function. So i think this will be best solution for you i think.
let's run following commands:
npm install bootstrap --save
npm install jquery --save
npm install popper.js --save
Now after successfully run above command. let's import it in angular.json file.
angular.json
....
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js"
]
.....
Now you can easily use bootstrap class as like bellow:
src/app/app.component.html
<div class="container">
<h1>Install Bootstrap 5 in Angular 14 - ItSolutionStuff.com</h1>
<div class="card">
<div class="card-header">
Featured
</div>
<div class="card-body">
<h5 class="card-title">Special title treatment</h5>
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
</div>
Now you can use bootstrap css and js both.
Run Angular App:
All the required steps have been done, now you have to type the given below command and hit enter to run the Angular app:
ng serve
Now, Go to your web browser, type the given URL and view the app output:
http://localhost:4200
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Upgrade from Angular 13 to Angular 14 Version Example
- Angular Material Checkbox Change Color Example
- Angular Material Multi Select Dropdown with Chips Example
- Angular Material Select Option Group Example
- Angular Material Multi Select Dropdown with Search Example
- Angular Material Multi Select Dropdown Example
- Angular Bootstrap Carousel Example
- Bootstrap Datetimepicker Disable Specific Dates Example
- Angular Material Slide Toggle Example
- Angular Material Mat-Select with Reactive Form Example