facebook / stylex

StyleX is the styling system for ambitious user interfaces.
https://stylexjs.com
MIT License
8.21k stars 304 forks source link

Question: what pattern should be used for DRY values in style keys? #610

Closed slightly-askew closed 1 week ago

slightly-askew commented 1 week ago

Describe the feature request

Hey. I've previously assigned media values to a variable (either globally or per-file):

CleanShot 2024-06-20 at 12 23 30

I would happy keeping the magic number value in my .stylex.ts file and importing it, but I can't seem to do that without getting an error either—it needs to be the full variable object. I have responsive tokens in my variables file but keeping arbitrary component styles such as the screenshot example in a external .stylex.ts file feels a little abstract imho.

Is there an idiomatic way to achieve this in Stylex that I have missed?