How to add custom CSS files globally for angular 6 project
1: Configure angular.json:
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"styles.scss"
]
2: Import directly in src/style.css or src/style.scss:
@import '~bootstrap/dist/css/bootstrap.min.css';
Alternative: Local Bootstrap CSS If you added the Bootstrap CSS file locally, just import it in angular.json
"styles": [
"styles/bootstrap-3.3.7-dist/css/bootstrap.min.css",
"styles.scss"
],
or src/style.css:
@import './styles/bootstrap-3.3.7-dist/css/bootstrap.min.css';
I personally prefer to import all my styles in src/style.css since it’s been declared in angular.json already.
Any CSS style file added to styles array at angular.json will be injected to index.html
and will be a globally this mean any class added in these files you can use it inside any component.
another way is to add style file manually to index.html this work if the file host on cdn or in the assets folder.