I created a component in angular library.
If I create a class in the component.css
and use it in the component.html
it works fine.
But how to use a global style in this component?
Thanks,
Asked
Active
Viewed 2,958 times
0

Alireza Ahmadi
- 8,579
- 5
- 15
- 42

achraf ben alaya
- 11
- 1
- 3
-
1Use the file styles.css – Michael Mairegger Jul 27 '21 at 08:27
-
From Angular 9 it's more easy, see the docs:https://angular.io/guide/creating-libraries#managing-assets-in-a-library – Eliseo Jul 27 '21 at 08:52
1 Answers
1
In angular.json
you can add your global css
file:
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
]
Note that there is one default css
file named styles.css
in root folder.
Here is working sample: https://stackblitz.com/edit/global-appearance?file=src%2Fstyles.css

Alireza Ahmadi
- 8,579
- 5
- 15
- 42
-
am talking about adding style in angular library and not a simple angular project. – achraf ben alaya Jul 27 '21 at 10:03
-
@achrafbenalaya For library follow this one: https://stackoverflow.com/questions/53377419/how-to-add-global-style-to-angular-6-7-library – Alireza Ahmadi Jul 27 '21 at 10:06