Skip to main content

Current limitations

StyleX Variants deliberately keeps recipes static so the Babel transform can emit deterministic StyleX output. These constraints are checked at compile time:

  • Configuration and styles must be static inline literals.
  • Spreads, computed keys, external style objects and dynamic style functions are rejected.
  • Slots, slot variants and compoundSlots are supported when their configuration is static and declared inline.
  • sxv.extend must reference a base recipe declared in the same module. The compiler does not follow imported recipes yet.
  • The package currently targets ESM and Babel 8.
  • Composition APIs are not implemented yet.

Unsupported configuration​

The following patterns cannot be analyzed safely:

const styles = getStyles();
sxv({ base: styles });

sxv({ variants: { ...externalVariants } });
sxv({ variants: { tone: { primary: condition ? a : b } } });

sxv({
slots: { root: styles.root },
variants: { tone: externalVariants },
});

Keep the recipe configuration inline and use static StyleX style objects.