Component CSS Styling

Debates on approaches to styling components in frontend frameworks like React, Vue, and Svelte, including CSS-in-JS (e.g., Styled Components), scoped CSS modules, and inline styles versus traditional CSS.

📉 Falling 0.4x Web Development
3,295
Comments
18
Years Active
5
Top Authors
#6863
Topic ID

Activity Over Time

2009
5
2010
1
2011
10
2012
14
2013
30
2014
56
2015
216
2016
246
2017
332
2018
344
2019
282
2020
333
2021
343
2022
275
2023
337
2024
219
2025
205
2026
47

Keywords

tachyons.css e.g IMHO JS styles.css GWT components.com IMO HN twitter.com css components css js component styles js html react vue svelte

Sample Comments

conradludgate Nov 22, 2024 View on HN

I prefer scoped css, eg svelte or react with CSS modules. This allows one to closely pair the styles with the component, but still separate out the styling from the html (I cannot stand tailwind/inline syles)

warent Nov 28, 2019 View on HN

You're misunderstanding. Styled components is a specific concept that uses CSS within JS: https://www.styled-components.com/The mess with CSS comes from the difficulty of code resuability once an application becomes complicated. Things start colliding and patterns diverge easily.

nailer Dec 2, 2022 View on HN

It’s odd, judging from a lot of the HN comments in the recent tailwind article, people find the lack of CSS inside react components (out of the box, I’m sure there’s ways of setting it up) enough of a hassle they want to style things in HTML - just to keep their styling in the same component. Something Vue and Svelte and others solve out of the box.

hiyer Dec 6, 2023 View on HN

What's the advantage of css in js as opposed to just plain css?

scabby Aug 16, 2023 View on HN

If you work with components then why not just use CSS?

troupo Oct 14, 2024 View on HN

In component-based apps/systems C in CSS is often the last thing you want, if you ever want that.

lfischer Nov 16, 2019 View on HN

What you describe sounds like the way some use CSS-in-JS frameworks as emotion or Styled Components.

theturtletalks Nov 29, 2022 View on HN

This is not the way either. I use CSS-in-JS which has its own flaws, but CSS stays with the component.

kall Mar 11, 2021 View on HN

I think the author is arguing for using something like styled-jsx, which is the same as vue SFC styles afaik. That stays fairly manageable and readable as well.

Touche Feb 18, 2019 View on HN

Why do you think CSS-in-JS has only caught on in the React community?