AngularJS: CSS in JS

Kent C. Dodds
2 min readNov 9, 2014

I was intrigued by the slides from Vjeux entitled “React: CSS in JS” (which is very good stuff and I would encourage you to read through it). I decided to see what it would look like to create something similar with Angular. turns out it’s not that bad and it’s actually kind of refreshing. I think I’ll keep looking into this…

Here’s a demo that I built when experimenting with the concept:

So there’s definitely room for additional abstractions here to make it easier to manage, but I can see some serious potential with this approach and will definitely investigate it further (perhaps even release a library with the necessary abstractions). It’s actually sort of delightful to write styles this way…

What are your thoughts on this? In my mind, I see ReactJS personified as a ninja with a sword called JavaScript and he’s whacking away at HTML and CSS (not as cool ninjas apparently) because he doesn’t need them anymore. Maybe that’s a little strong for what is actually going on, but I think the imagery is kind of cool.

TestingJavaScript.com Learn the smart, efficient way to test any JavaScript application.

--

--

Kent C. Dodds

Making software development more accessible · Husband, Father, Latter-day Saint, Teacher, OSS, GDE, @TC39 · @PayPalEng @eggheadio @FrontendMasters · #JS