Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS Encapsulation not passed down to child elements, breaks styling #151

Open
YeomansIII opened this issue Jan 2, 2017 · 2 comments
Open

Comments

@YeomansIII
Copy link

YeomansIII commented Jan 2, 2017

It's impossible to style elements that are created within the ng-semantic elements when CSS encapsulation is enabled. This makes it impossible to fine tune styling of specific generated elements.

For example, the generated divs within an <sm-progress></sm-progress> element. This element generates multiple divs such as the "bar" and progress text. None of this can be styled from the component that includes this ng-semantic element because the generated elements (such as "bar" and progress text) do not include the components CSS isolation attribute (such as "_ngcontent-pgr-32").

I'm not sure if this is even possible, but it only makes sense to allow CSS to fine tune the content that is generated by these ng-semantic elements.

@Fanmeter
Copy link

I have a same issue. My current solution is to put ":host >>> " before each selector in your CSS file, which would be applied to elements inside ng-semantic component. Then the styles could be passed down the child tree.
check out here for Angular2's component style.

@Fanmeter
Copy link

Fanmeter commented Jan 19, 2017

@YeomansIII, another simple way to solve the problem.
In your component using <sm-*> component, add one more metadata setting encapsulation: ViewEncapsulation.None in @component decorator as the following:

import { Component, OnInit, ViewEncapsulation } from '@angular/core';
@Component({
  selector: 'your-selector',
  templateUrl: './yours.component.html',
  styleUrls: ['./yours.component.css'],
  encapsulation: ViewEncapsulation.None
})export class YourComponent implements OnInit {
    ...
}

Then you can keep your css file as usual and the style should be applied to the target element.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants