Skip to content

Conversation

@nmn
Copy link
Collaborator

@nmn nmn commented Sep 7, 2025

What changed / motivation ?

This adds a small syntactic sugar to allow using a sx= prop on lower-case html JSX elements as an alternative to {...stylex.props}

So you can write:

<div sx={[styles.foo, styles.bar]} />

instead of

<div {...stylex.props(styles.foo, styles.bar)} />

if you want.

This addresses a very common complaint.

Additional Context

A single test has been added.

This PR is not quite ready to merge yet. The transformation is currently hardcoded.

Pre-flight checklist

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 7, 2025
@github-actions
Copy link

github-actions bot commented Sep 7, 2025

workflow: benchmarks/perf

Comparison of performance test results, measured in operations per second. Larger is better.

[email protected] compare
node ./compare.js /tmp/tmp.LpDEPTYkie /tmp/tmp.HqZx70gR44

Results Base Patch Ratio
babel-plugin: stylex.create
· basic create 653 635 0.97 -
· complex create 192 187 0.97 -
babel-plugin: stylex.createTheme
· basic themes 458 450 0.98 -
· complex themes 43 42 0.98 -

@github-actions
Copy link

github-actions bot commented Sep 7, 2025

workflow: benchmarks/size

Comparison of minified (terser) and compressed (brotli) size results, measured in bytes. Smaller is better.

[email protected] compare
node ./compare.js /tmp/tmp.efLTW28HRL /tmp/tmp.w4ewnaZt6s

Results Base Patch Ratio
@stylexjs/stylex/lib/cjs/stylex.js
· compressed 1,190 1,190 1.00
· minified 3,541 3,541 1.00
@stylexjs/stylex/lib/cjs/inject.js
· compressed 1,223 1,223 1.00
· minified 3,216 3,216 1.00
benchmarks/size/.build/bundle.js
· compressed 496,650 496,650 1.00
· minified 4,847,840 4,847,840 1.00
benchmarks/size/.build/stylex.css
· compressed 99,853 99,853 1.00
· minified 747,541 747,541 1.00

Copy link

@xrzhuang xrzhuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omg i need this now !!!!

ship it 🚀

@mellyeliu
Copy link
Member

not sure if we could use this internally with Flow etc, but will try to collect feedback on naming regardless

@matclayton
Copy link

This would be amazing, if you could get it working on flow especially. We're migrating to stylex at the moment and this is one of my personal pet peeves. We're also on flow (and relay), could you get the flow team to add a custom config like relay has relay_integration=true so it becomes stylex aware, and handles it accordingly?

@zaydek
Copy link

zaydek commented Oct 9, 2025

This would be a big help. Would love to see this so I don't have to alternate between {...stylex.props(…)} and sx={…} depending on if it's an intrinsic element or a component.

@mellyeliu
Copy link
Member

Will sync with the Flow team on support for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants