Settings

Theme

Facebook Open Sources StyleX

github.com

27 points by zodvik 2 years ago · 3 comments

Reader

sdflhasjd 2 years ago

JSX is so good because it's an effective language extension, but CSS-in-JS still feels like a dirty mess, everything just becomes strings in objects, it just takes the elegance of the CSS syntax and throws it out the window.

Like, look at this:

  const styles = stylex.create({
    base: {
      width: {
        default: 800,
        '@media (max-width: 800px)': '100%',
      },
    },
  });
Hmmmm
mdhb 2 years ago

CSS in JS was such a dumb mistake. This really shouldn’t be a serious consideration in 2023.

  • matesz 2 years ago

    Unfortunatelly this is the state of software these days - half-baked libraries + incremental improvements. This doesn't work in most cases. I wouldn't call it mistake though, open sourcing anything is a good thing.

    The right solution is a library like this with proper cross-platform abstraction. Then you can simply compile css-in-js to stylesheets to have caching, therefore fully utilizing platforms capabilities.

    Who cares whether css is written in css files or js files or whatever. Abstraction + solid tooling (compilation) + ide support is the way.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection