adding bootstrap to angular
To add Bootstrap to an Angular project, you can follow these steps:
- Install Bootstrap using npm by running the following command in your project directory:
npm install bootstrap
Open the
angular.json
file in your project's root directory.Locate the
"styles"
array inside the"architect"
>"build"
>"options"
section.Add the path to the Bootstrap CSS file in the
"styles"
array. By default, it should be"node_modules/bootstrap/dist/css/bootstrap.min.css"
. Yourangular.json
file should have a similar structure to this:
"architect": {
"build": {
"options": {
"styles": [
"src/styles.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css"
],
...
},
...
},
...
}
Save the
angular.json
file.Open the
src/styles.css
file in your project.Import the Bootstrap JavaScript file by adding the following line at the beginning of the file:
@import '~bootstrap/dist/css/bootstrap.min.css';
- Save the
styles.css
file.
Bootstrap is now added to your Angular project. You can start using Bootstrap classes and components in your HTML templates. Remember to import any additional Bootstrap JavaScript files if needed.
For further customization and usage of Bootstrap in Angular, you can refer to the official Bootstrap documentation.