[Angular] Styles in .css files are not applied
See original GitHub issueIssue details
Styles in .css files are not applied to Storybook’s iframe:
I wrote the following component with styleUrls:
/* my-button.component.ts */
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-my-button',
templateUrl: './my-button.component.html',
// use `styleUrls`: styles are not applied...
styleUrls: ['./my-button.component.css'],
})
export class MyButtonComponent {
}
and
/* my-button.component.css */
p {
color: red;
}
But the component rendered by Storybook is not applied this style ( the font-color is black).
And I use not styleUrls but styles:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-my-button',
templateUrl: './my-button.component.html',
// use `styles`: red color applied
styles: [`
p {
color: red;
}
`],
})
export class MyButtonComponent {
}
then, the component gets red colored.
Steps to reproduce
I’ve created the reproducing repo:
git clone https://github.com/Quramy/storybook-ng-css.git
cd storybook-ng-css
npm run storybook
Please specify which version of Storybook and optionally any affected addons that you’re running
@storybook/angular: 3.3.3
And:
@angular/core: 5.1.2@angular/cli: 1.5.4
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
CSS is not working in my angular component - Stack Overflow
The CSS classes in my rating.component.ts file are not working. My project is compiling because I can add text to my rating component...
Read more >Component styles - Angular
Reminder: the styles in the style file apply only to this component. They are not inherited by any components nested within the template...
Read more >CSS style sheet not loading or linking with HTML
The problem may be that your browser is caching the CSS file. If you're debugging with Edge, you can open the F12 tools...
Read more >Angular :host, :host-context, ::ng-deep - The Complete Guide
So this style will be applied to all h2 elements inside app-root , but not outside of it as expected. This combination of...
Read more >Avoid global styles in your Angular projects
CSS is the language used to style HTML pages. It has a simple set of rules to compute values of properties of every...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think start from the
docs/src/pages/basics/guide-angular/index.md=)@igor-dv Thanks for your reply.
Styles in .css(or .scss) files are applied with the following webpack config: