adding bootstrap to angular global styles
To add Bootstrap to the global styles in Angular, you can follow these steps:
- Install Bootstrap: Run the following command in your Angular project's root directory to install Bootstrap using npm (Node Package Manager):
npm install bootstrap
- Import Bootstrap styles: Open the
styles.scss
file located in thesrc
folder of your Angular project. Add the following line at the top of the file to import Bootstrap styles:
@import '~bootstrap/scss/bootstrap';
Save the file: Save the
styles.scss
file after adding the import statement.Angular CLI configuration: Open the
angular.json
file located in the root directory of your Angular project. Find the"styles"
property under"architect"
->"build"
->"options"
. Add the following path to the array of styles:
"node_modules/bootstrap/dist/css/bootstrap.min.css"
The updated "styles"
property should look like this:
"styles": [
"src/styles.scss",
"node_modules/bootstrap/dist/css/bootstrap.min.css"
],
- Save the file: Save the
angular.json
file after adding the Bootstrap path.
That's it! Bootstrap has now been added to the global styles in your Angular project. You can now use Bootstrap classes and components throughout your application.
Note: Make sure to restart the Angular development server (ng serve
) if it was already running for the changes to take effect.
I hope this helps! Let me know if you have any further questions.