AI agents misuse xstyle prop — pass inline objects instead of stylex.create()
Description
AI agents (e.g. Claude) incorrectly pass inline style objects to the xstyle prop on XDS components, treating it like React's style prop.
Incorrect (what agents write)
<XDSButton xstyle={{ cursor: 'pointer' }} />
Correct
import stylex from '@stylexjs/stylex';
const styles = stylex.create({
withPointer: {
cursor: 'pointer',
},
});
// ...
<XDSButton xstyle={styles.withPointer} />
Context
xstyle accepts a StyleXStyles value produced by stylex.create(), not a plain CSS object. This is a common mistake for agents that are familiar with React's style prop but haven't internalized the StyleX mental model.
This could potentially be addressed by:
- Better type-level error messages (if possible via StyleX types)
- Documentation / AI-facing guidance clarifying the
xstylecontract - Runtime warnings in dev mode when a plain object is passed
This is actually a valid stylex input.
I was actually thinking to do the opposite: document all 3 kinds of stylex inputs as options so we can support XDS outside of using stylex.
Superseded by #506 — the className prop replaces xstyle as the primary consumer override mechanism. className is universally understood by LLMs and doesn't require StyleX knowledge.