News for hackers. Stuff that matters.
Re:StyleX – Meta's styling library by willsmith72 on Tuesday December 05, 2023 @06:40PM (#38538503)
I hate having to give everything a name like people do in react native stylesheets. Give me an inline performant style prop any day
Re:StyleX – Meta's styling library by cantSpellSober on Tuesday December 05, 2023 @07:42PM (#38539033)
You already have to name your CSS classes, and atomic CSS libraries are chock full of names you must learn.

What do you mean "inline style prop," writing CSS in the HTML style attribute? That's a nightmare to manage across large apps, not composable or reusable, and this library compiles to performant styling (according to the authors/examples).

Re:StyleX – Meta's styling library by yurishimo on Tuesday December 05, 2023 @08:09PM (#38539269)
Nitpick, but most atomic css libraries name things fairly consistently. In addition, you only have to memorize the names once. After that learning curve, you never have to think of a class name again.

In addition, with robust IDE support, you can type the css attribute and get autocomplete suggestions for the relevant utility.

Re:StyleX – Meta's styling library by cantSpellSober on Tuesday December 05, 2023 @09:28PM (#38539845)
So we're told every time. Is it "2xl" or "xxl" for the breakpoint again? It depends on the library (hopefully you didn't customize it!). Was it Tachyons or Bulma that has "ns" for "not small?"

> you only have to memorize the names once

Yep! After that it's as simple as dark:hover:md:motion-reduce:text-base/7

> you never have to think of a class name again

Unless you're using Tailwind's custom themes, arbitrary groups, peers...

Re:StyleX – Meta's styling library by willsmith72 on Tuesday December 05, 2023 @11:05PM (#38540376)
e.g. using mui sx. the downside is the runtime performance cost

https://mui.com/system/getting-started/usage/#performance-tr...

i don't want to reuse or compose my styles, i just want to add alignSelf: 'flex-end' and then easily be able to change it and see the styles in one place, without leaving the component definition. the reusability and composition is at the component level

Re:StyleX – Meta's styling library by cantSpellSober on Wednesday December 06, 2023 @07:43AM (#38543095)
Thanks! Great reason this beats MUI.

Not trying to hate on atomic CSS, we've had composable classes and style tokens for a long time, they work well. Even one of the devs on this project commented on them here:

> We don't think the Tailwind way of styling is readable in the long term, but we see the value is being able to author that way

https://news.ycombinator.com/item?id=38540629

The docs here mention the downsides though.

Re:StyleX – Meta's styling library by willsmith72 on Wednesday December 06, 2023 @09:23AM (#38544233)
> Great reason this beats MUI.

Not at all, mui gives you the option to do either.

I don't want my style library being opinionated about my coding style.

Re:StyleX – Meta's styling library by cantSpellSober on Wednesday December 06, 2023 @11:45AM (#38546268)
Ohh I see, I honestly didn't click the first time. You meant sx in MUI, not StyleX. We're gonna need more names.
Re:StyleX – Meta's styling library by Zababa on Wednesday December 06, 2023 @08:39AM (#38543706)
To anyone for which learning lots of names of things that you use semi-frequently is a bottleneck: you can use spaced repetition (https://en.wikipedia.org/wiki/Spaced_repetition) to remember them way more easily. I use Anki (https://apps.ankiweb.net/), SuperMemo is another option (with other features, and lots of interesting articles on their website).

For example, I've been using it to remember shell commands and options. Now whenever I have to search for an option that I think will be useful in the future, for example `-M/--max-columns` for ripgrep, I put it in Anki (question: "Ripgrep: Search for 'clukay' and don't print columns longer than 200 bytes", answer: "rg -M/--max-columns 200 clukay"). Each day I review my cards (~5/10 minutes at most). I used to not be able to remember an option like that that I use once a week, but now I can.

For more info on how to use it effectively, I've found https://borretti.me/article/effective-spaced-repetition to be really helpful.

Re:StyleX – Meta's styling library by candiddevmike on Tuesday December 05, 2023 @07:47PM (#38539065)
Inline styles by themselves don't support a lot of necessary CSS things like media and child selectors. You lose the "cascading" part of CSS...
Re:StyleX – Meta's styling library by nwienert on Tuesday December 05, 2023 @08:32PM (#38539437)
Try out Tamagui which solves this - child and media selectors, even container queries and stuff like container + pseudo.
Re:StyleX – Meta's styling library by cantSpellSober on Tuesday December 05, 2023 @10:17PM (#38540139)
Unclear if they mean inline styles as in "the HTML attribute" or a React prop. Tamagui doesn't solve the former.
Re:StyleX – Meta's styling library by naman34 on Wednesday December 06, 2023 @12:02AM (#38540629)
Hey! I'm the maintainer of StyleX and I just wanted to say that you would probably like PandaCSS or Tamagui.

We don't think the Tailwind way of styling is readable in the long term, but we see the value is being able to author that way. We're looking into a VS Code plugin, that would let you author your styles inline and extract them out when you save.

Re:StyleX – Meta's styling library by willsmith72 on Wednesday December 06, 2023 @09:27AM (#38544270)
Fair enough, that would be a good start. I just see such a smooth workflow in being able to do styles for elements with only a few custom styles inline.

I mentioned below, I do this with mui sx right now when <= 4 styles

E.g. sx={{ alignSelf: 'flex-end' }}

I think the reason it works so well is the same reason people love tailwind (it's all in one place), so the plugin would be helpful but still take away from that workflow when it comes to reading and maintaining.