An open source design system that's fully customizable and agent ready
TypeScript
docs(cli): document xstyle unified override formats (#482)
Cindy Zhang9a86940e2992
diff --git a/packages/cli/docs/principles.md b/packages/cli/docs/principles.mdindex e022cc6954..55d030467b 100644--- a/packages/cli/docs/principles.md+++ b/packages/cli/docs/principles.md@@ -10,9 +10,50 @@ React design system for internal tools. Components use `XDS` prefix.4. CSS variables for colors, not hex5. Form inputs are controlled (value + onChange)+## Style Overrides: xstyle prop++Most XDS components accept an `xstyle` prop for customizing styles.+It supports three formats — pick the one that fits:++**Inline styles** — for simple one-off overrides:++```tsx+<XDSTextInput label="Name" xstyle={{ maxWidth: 300 }} />+<XDSCard xstyle={{ height: 200, padding: 16 }} />+```++**StyleX styles** — for complex, reusable, or pseudo-class overrides:++```tsx+import * as stylex from '@stylexjs/stylex';+const overrides = stylex.create({+ hoverCard: {+ boxShadow: {+ default: 'none',+ ':hover': {'@media (hover: hover)': '0 4px 12px rgba(0,0,0,0.15)'},+ },+ },+});+<XDSCard xstyle={overrides.hoverCard} />;+```++**CSS class name** — for Tailwind, CSS Modules, or external CSS:++```tsx+<XDSCard xstyle="my-custom-card" />+<XDSCard xstyle={styles.customCard} /> // CSS Module+```++Rules of thumb:++- 1-2 simple properties → inline+- 3+ properties, reusable, or named → `stylex.create`+- Pseudo-classes (`:hover`, `:focus-visible`) → `stylex.create` (required)+- All `:hover` MUST use `@media (hover: hover)` guards+## Anti-Patterns-❌ Inline styles → Use StyleX+❌ Inline styles on raw elements → Use `xstyle` on XDS components❌ Hardcoded colors (#fff) → Use var(--color-_)❌ Hardcoded spacing (16px) → Use spacing tokens or var(--spacing-_)❌ Inventing props → Read component docs firstdiff --git a/packages/cli/src/commands/component.mjs b/packages/cli/src/commands/component.mjsindex 7db0037e90..a597cf9a43 100644--- a/packages/cli/src/commands/component.mjs+++ b/packages/cli/src/commands/component.mjs@@ -617,6 +617,14 @@ export function extractBriefAll(coreDir) {const components = discoverComponents(coreDir);const output = [];+ // Add xstyle override hint at the top+ output.push(+ `> **Style overrides:** Most components accept an \`xstyle\` prop.`,+ `> Use inline objects for simple overrides: \`xstyle={{ maxWidth: 300 }}\``,+ `> Use \`stylex.create()\` for pseudo-classes/media queries or 3+ properties.`,+ `> See \`npx xds docs principles\` for details.\n`,+ );+for (const [category, comps] of Object.entries(components)) {output.push(`## ${category}\n`);for (const comp of comps) {