astryx icon indicating copy to clipboard operation
astryx copied to clipboard

AI agents misuse xstyle prop — pass inline objects instead of stylex.create()

Open ejhammond opened this issue 8 months ago • 3 comments

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 xstyle contract
  • Runtime warnings in dev mode when a plain object is passed

ejhammond avatar Mar 05 '26 22:03 ejhammond

This is actually a valid stylex input.

cixzhang avatar Mar 06 '26 23:03 cixzhang

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.

cixzhang avatar Mar 06 '26 23:03 cixzhang

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.

cixzhang avatar Mar 07 '26 18:03 cixzhang