Skip to content
created by Aha00aAha00a at 2020-11-20
last modified by Aha00aAha00a at 2021-08-15
revision: 6

CSS-in-JS

Article

초창기 Component Driven Development를 할 때 HTML, JavaScript, CSS코드가 분리되어 Shotgun Surgery를 할 수 밖에 없었는데, 차츰 JSX를 통해 JavaScript안으로 HTML이 흡수통합되는 방식으로 개선되게 되었다. 이 CSS-in-JS도 마찬가지로, 동떨어져 있던 CSSJavaScript안으로 흡수하기 위한 노력이다.

경쟁자들이 아주 많은데, 그 중에서 styled-componentsemotion을 주목했다. styled-components는 지배율이 압도적이고, emotion은 기능과 지원범위가 넓어 보였기 때문. 하지만 이는 2017년의 이야기였을 뿐, 결국 2020-11-20 시점에 이르러서는 서로가 서로의 기능들을 경쟁적으로 흡수하여 거의 비슷한 수준이라고 한다.

결론

  • styled-components: 사용자들이 많기에 정보가 많다.
  • emotion: 후발주자로서 좀 더 fancy한 문법에 좀 더 작고 빠르다.
  • 서로 경쟁하다보니 지금에 와서는 서로 교체가 힘들지 않다.

--2020-11-20

  • css-tricks - Ollie Williams - The Fragmented, But Evolving State of CSS-in-JS
    • 2018-12-27에 작성된 글. 제목을 번역해 보자면 "단편화 되었지만, 진화하고 있는 CSS-in-JS". 경합하는 많은 라이브러리들이 비슷한 API로 수렴하고 있다는 이야기.

      The rival CSS-in-JS libraries have stolen from each other until landing upon the same feature set and the same syntax — Emotion and Styled Components have an almost identical API. What once felt like a total mess of competing methodologies and libraries now feels somewhat stable. Even if CSS-in-JS hasn’t standardized on a dependency, it now has standardized a way of doing things — they’re just implemented differently:

      --2020-11-20
  • spectrum.chat - styled-components - Emotion vs Styled Components
    • styled-components와 emotion을 비교하는 쓰레드. 18개월간 둘 다 써봤는데 결국 서로 비슷하기에 아주 적은 노력으로 교체할 수 있다는 말이 와닿는다. 그렇다. 항상 정답은 둘 다 사라였던 거였지..

      Nick Gault at 2019-12-24

      Our small team has been spread between styled-components & emotion for almost 18 months. Looking forward, performance and functionality differences are, for practical purposes, negligible. Either library can be swapped out for the other with minimal effort.

      --2020-11-20

2. See Also

2.2. Similar Pages

Similar pages by cosine similarity. Words after page name are term frequency.

  • 43.76% styled-components styled(12:8), components(7:8), css(11:2), js(8:4), and(4:1), with(1:4), for(3:1), npm(1:2), api(1:1), component(1:1)

2.3. Adjacent Pages

Control
≤ 32
all
1.0x
1.0x
80
-120
ON
Metrics
Nodes(visible/total)0/0
Links(visible/total)0/0
Avg degree0.00
Depth coverage0
Queue(fetch/graph)0 / 0
Zoom(scale)1.00x
Ctrl/⌘ + Scroll: Zoom
Root 1-hop 2-hop+