css-modules-angular2
css-modules-angular2 copied to clipboard
question - what if the css class name as a dash in its name
import styles from "./button.css";
@Component({
selector: 'buttone',
template: `<button class="${styles.some-btn}">test</button>`,
})
is there a way to make the class .some-btn to be find, somehow the dash breaks the reference. thanks
I got an alternative solution to make it work by using
import classNames from 'classnames/bind';
[(https://github.com/JedWatson/classnames)]
to help multiple css import.
I'm evaluating if I should use [ngClass]
for dynamic class name or cx()
from classNames is OK.
Any thoughts about that ? Since I have a React background some Angular particularities are unknown to me.
Hello,
Yes typically for dynamic classes ngClass would be the answer =).I am still evaluating CSS modules. I like the structure and the fact that it really is effective in removing unused CSS in a way that is a bit more difficult in other ways. That being said if you are just using css Angular's CSS mechanism is also capable of doing the same. if scopes CSS and can also find unused CSS if using a tool like codelyzer (https://twitter.com/mgechev/status/833961783521980416)
What I still havent been able to do is get CSS modules to work with AOT.
@joaogarin did you ever get css modules to work with aot? And do you have an example in creating a share css module (node_module)?