TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

StyleX – Meta's styling library

111 pointsby alexarenaover 1 year ago

20 comments

CharlesWover 1 year ago
This is probably a better place to start: <a href="https:&#x2F;&#x2F;stylexjs.com&#x2F;blog&#x2F;introducing-stylex&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;stylexjs.com&#x2F;blog&#x2F;introducing-stylex&#x2F;</a><p>&gt; <i>We created StyleX not only to meet the styling needs of React developers on the web, but to unify styling for React across web and native.</i><p>Meta friends, the names &quot;Review&quot; and &quot;Restyle&quot; were <i>right there</i>.
评论 #38538705 未加载
评论 #38538692 未加载
scopover 1 year ago
I really enjoy when libraries or languages have a “Thinking in X” post of some kind. I find it really helps orient me once I actually get to writing some code. If anybody has any “Thinking in X” examples that you have found particularly useful, let me know!
ryanarover 1 year ago
It was React Conf 2018 in Nevada when they first talked about StyleX and said they planned to open source it. Though I thought it was going to come much sooner than 5 years, I am so glad it has been released! 2018 was peak css-in-js era and StyleX approach of deduping classes and remove runtime JS was a really performant approach and it sounded like the DX was nice as well.<p><a href="https:&#x2F;&#x2F;youtu.be&#x2F;9JZHodNR184?t=270" rel="nofollow noreferrer">https:&#x2F;&#x2F;youtu.be&#x2F;9JZHodNR184?t=270</a>
jsf01over 1 year ago
Just at a cursory glance, this looks pretty verbose and clunky. Existing React ecosystem styling solutions are many, so it’s not immediately evident to me when you would accept the trade offs introduced by this tool over any existing ones that seem much nicer to not only integrate, but also have to work with day to day.
评论 #38538549 未加载
评论 #38538678 未加载
dmalikover 1 year ago
This looks interesting and I&#x27;ll play around with it. It will be tough to replace CSS modules and plain CSS for my React apps though. CSS is so much better now. Did you know you can nest in CSS natively now? <a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;CSS&#x2F;CSS_nesting" rel="nofollow noreferrer">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;CSS&#x2F;CSS_nesting</a>
评论 #38550067 未加载
willsmith72over 1 year ago
I hate having to give everything a name like people do in react native stylesheets. Give me an inline performant style prop any day
评论 #38540629 未加载
评论 #38539033 未加载
评论 #38539065 未加载
mdhbover 1 year ago
Part of me was holding out hope that React and it’s surrounding ecosystem might at some point end up back on a path that is somewhat more aligned with the rest of the web and had some meaningful sense of interoperability with everything that’s not React.<p>This certainly inspired no confidence in that.<p>All I will say is that CSS has gotten a LOT better in the past 5 years and for almost every scenario I can think of you would be in such a better position if you just spent a month learning that rather than this new abstraction.
评论 #38542882 未加载
stephenover 1 year ago
Nice! We copied StyleX&#x27;s &quot;type-safe extensions&quot; in Truss [1] so things like `&lt;MyButton xss={Css.mt5.$} &#x2F;&gt;` are allowed (setting margin is fine) while disallowing `&lt;MyButton xss={Css.dg.$} &#x2F;&gt;` (anything &quot;not margin&quot;) that would mess up the components internal impl details with a compile error.<p>That said, we don&#x27;t actually use the feature that much, vs. higher-level logical props like `&lt;MyButton compact &#x2F;&gt;`.<p>I know we&#x27;re supposed to use build-time CSS-in-JS these days, but afaiu they don&#x27;t support the rare-but-handy &quot;just spread together ~4-5 different object literals from ~random different conditionals + props&quot;, i.e. intermixing styles some inside the component + outside the component, which emotion handles really well.<p>Basically this [2]. StyleX says it does &quot;cross-file styles&quot;...but can it support that? I kinda assume not, but I&#x27;m not sure.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;homebound-team&#x2F;truss#xstyles--xss-extension-contracts">https:&#x2F;&#x2F;github.com&#x2F;homebound-team&#x2F;truss#xstyles--xss-extensi...</a><p>[2]: <a href="https:&#x2F;&#x2F;github.com&#x2F;homebound-team&#x2F;beam&#x2F;blob&#x2F;main&#x2F;src&#x2F;components&#x2F;Table&#x2F;components&#x2F;Row.tsx#L246">https:&#x2F;&#x2F;github.com&#x2F;homebound-team&#x2F;beam&#x2F;blob&#x2F;main&#x2F;src&#x2F;compone...</a>
评论 #38539478 未加载
评论 #38540583 未加载
Bishonen88over 1 year ago
Their introduction page[0] makes this look like material ui&#x27;s makeStyles[1] approach?<p>[0] <a href="https:&#x2F;&#x2F;stylexjs.com&#x2F;docs&#x2F;learn&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;stylexjs.com&#x2F;docs&#x2F;learn&#x2F;</a> [1] <a href="https:&#x2F;&#x2F;mui.com&#x2F;system&#x2F;styles&#x2F;basics&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;mui.com&#x2F;system&#x2F;styles&#x2F;basics&#x2F;</a>
评论 #38543453 未加载
askonommover 1 year ago
It always surprises me the lengths people are willing to go to avoid writing CSS. If organization is the issue, there&#x27;s BEM (<a href="https:&#x2F;&#x2F;getbem.com&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;getbem.com&#x2F;</a>). This just looks like another layer of complexity on top of an already convoluted front-end stack that just slows everything it touches to a crawl and only works moderately well on the developers beefed up latest MacBook Pro&#x27;s, and sucks horribly on any regular person&#x27;s computer.
评论 #38539941 未加载
djsteinover 1 year ago
waited a long time for this since they first demoed it at react conf 2018? in vegas. this was the last piece in the SSR + streaming + suspense holy grail. looks like the pieces are all finally done. congrats on the launch
cantSpellSoberover 1 year ago
Borrows a lot from emotion&#x2F;styled-components it appears. The extensive typing seems to be the biggest feature.<p>They mention why I should choose it over BEM or Tailwind, why choose it over MUI though?
评论 #38538834 未加载
danr4over 1 year ago
Excited to explore just for the sake of alleviating “styling at a distance” pains
rsstackover 1 year ago
How does this compare to <a href="https:&#x2F;&#x2F;griffel.js.org&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;griffel.js.org&#x2F;</a> ?
评论 #38539048 未加载
incrudibleover 1 year ago
React is one of these things that was designed to be unbeareable tonuse without custom syntax, but at least it is <i>possible</i>. This looks looks like it does not work without custom syntax at all. Type safety is a nice to have, but it should not need an exotic compiler plugin.
评论 #38550456 未加载
webdood90over 1 year ago
Always impressed by how insanely overcomplicated people can make CSS.
评论 #38539043 未加载
评论 #38538916 未加载
评论 #38538757 未加载
hiyerover 1 year ago
What&#x27;s the advantage of css in js as opposed to just plain css?
评论 #38539210 未加载
评论 #38539231 未加载
评论 #38539201 未加载
评论 #38542047 未加载
mark_martover 1 year ago
I couldn’t see pseudo selector (like :hover) support in the docs.
评论 #38538866 未加载
评论 #38538827 未加载
nojvekover 1 year ago
CSS in JS is really a great concept to keep component logic colocated.<p>Although I’m really in love with @emotion&#x2F;css where I can still write and copy paste css-snippets instead of translating into js object syntax.
max_over 1 year ago
It looks like the React-ification of CSS. No thanks!
评论 #38538525 未加载
评论 #38538869 未加载