Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

initial architecture proposal

Cindy Zhanga5f2ddc051c7
diff --git a/.context/explorations/frontend-developer-jtbd.md b/.context/explorations/frontend-developer-jtbd.md
new file mode 100644
index 0000000000..cc35356e63
--- /dev/null
+++ b/.context/explorations/frontend-developer-jtbd.md
@@ -0,0 +1,149 @@
+# Frontend Developer Jobs To Be Done
+
+*Exploration — January 2026*
+
+## Context
+
+Research into the jobs frontend developers are trying to accomplish when setting up and building with UI systems. Goal: ensure XDS serves the right jobs and doesn't over-engineer for jobs that don't exist.
+
+---
+
+## Research Findings
+
+### Core Developer Jobs (from research)
+
+| Job | Description | Frequency |
+|-----|-------------|-----------|
+| **Translate designs to code** | Convert mockups/specs into functional UI | Daily |
+| **Maintain consistency** | Ensure visual/behavioral consistency across app | Ongoing |
+| **Test across environments** | Verify UI works in different browsers/devices | Per feature |
+| **Collaborate with team** | Work with designers, backend, other devs | Daily |
+| **Optimize performance** | Reduce load times, improve responsiveness | Periodic |
+| **Debug issues** | Fix visual bugs, interaction problems | As needed |
+
+Source: [Guvi: What Does a Front End Developer Do](https://www.guvi.in/blog/what-does-a-front-end-developer-do/)
+
+### Design System-Specific Jobs
+
+| Job | Pain Point When Unmet |
+|-----|----------------------|
+| **Discover available components** | "Teams don't know what's available in the system" |
+| **Trust component documentation** | "Developers question whether documented components match production reality" |
+| **Integrate with existing toolchain** | "System components don't fit existing toolchains or workflows" |
+| **Reduce design-to-code translation** | "Manual interpretation creates rework and inconsistency" |
+| **Keep implementations current** | "Updating implementations when systems evolve" |
+
+Source: [Netguru: Design System Adoption Pitfalls](https://www.netguru.com/blog/design-system-adoption-pitfalls)
+
+### Key Insight: Adoption > Features
+
+"Design systems aren't failing because they're poorly built—they're failing because no one's using them."
+
+The solution isn't technical—it's organizational, requiring:
+- Clear ownership structures
+- Active team engagement
+- Easy discovery
+- Trust in the system
+
+---
+
+## XDS Builder Jobs Framework
+
+Based on research, here are the jobs XDS should serve:
+
+### Setup Phase Jobs
+
+| Job | What Success Looks Like |
+|-----|------------------------|
+| **Set up project styling** | Define tokens, themes in one place; immediate visual consistency |
+| **Configure for my stack** | Works with my build tools, framework, IDE |
+| **Adopt incrementally** | Can start with one component, expand over time |
+
+### Build Phase Jobs
+
+| Job | What Success Looks Like |
+|-----|------------------------|
+| **Construct pages from components** | Compose UI quickly with typed props, autocomplete |
+| **Customize component appearance** | Theme changes propagate everywhere automatically |
+| **Handle edge cases** | Swizzle when needed, clear escalation path |
+| **Stay consistent with design** | Components match design specs out of the box |
+
+### Maintain Phase Jobs
+
+| Job | What Success Looks Like |
+|-----|------------------------|
+| **Update to new versions** | Clear migration path, deprecation warnings |
+| **Debug visual issues** | Predictable styles, easy to trace |
+| **Scale to more features** | System grows with app, no breaking changes |
+
+### Collaborate Phase Jobs
+
+| Job | What Success Looks Like |
+|-----|------------------------|
+| **Share patterns with team** | Components are self-documenting, Storybook integration |
+| **Onboard new developers** | Props-only API, familiar patterns |
+| **Work with AI assistants** | Typed APIs, constrained options, predictable patterns |
+
+---
+
+## How XDS Maps to Jobs
+
+| XDS Layer | Primary Jobs Served |
+|-----------|---------------------|
+| **Theme Layer** | Set up styling, customize appearance, maintain consistency |
+| **Component API** | Construct pages, stay consistent, onboard developers, work with AI |
+| **Swizzle Layer** | Handle edge cases, customize beyond theme |
+| **CLI/Tooling** | Configure for stack, adopt incrementally, update versions |
+| **Storybook/Docs** | Discover components, share patterns, trust documentation |
+
+---
+
+## Jobs XDS Should NOT Try to Serve
+
+| Anti-Job | Why Not |
+|----------|---------|
+| **Backend/API development** | Out of scope |
+| **State management** | Different concern, many solutions exist |
+| **Routing/navigation logic** | Framework-specific |
+| **Data fetching** | Not a styling/component concern |
+| **Animation authoring** | Future phase, not core |
+
+---
+
+## Implications for Architecture
+
+### Must-Haves (serves core jobs)
+
+- Typed props API (construct pages, work with AI)
+- Theme system (set up styling, customize appearance)
+- Swizzle API (handle edge cases)
+- Good docs/Storybook (discover components, trust documentation)
+
+### Nice-to-Haves (serves secondary jobs)
+
+- CLI for scaffolding (configure for stack)
+- Migration tooling (update versions)
+- Tailwind interop (adopt incrementally for Tailwind users)
+
+### Won't-Do (not our jobs)
+
+- State management solutions
+- Routing components
+- Data layer abstractions
+
+---
+
+## Open Questions
+
+- Should we formally interview developers to validate these jobs?
+- Are there jobs specific to AI-assisted development we're missing?
+- How do enterprise vs indie developer jobs differ?
+
+---
+
+## Sources
+
+- [Guvi: What Does a Front End Developer Do](https://www.guvi.in/blog/what-does-a-front-end-developer-do/)
+- [Netguru: Design System Adoption Pitfalls](https://www.netguru.com/blog/design-system-adoption-pitfalls)
+- [Netguru: Frontend Development Process](https://www.netguru.com/blog/front-end-development-process)
+- [Digital Leadership: JTBD in UX Design](https://digitalleadership.com/glossary/jobs-to-be-done-ux/)
diff --git a/.context/explorations/stylex-vs-tailwind.md b/.context/explorations/stylex-vs-tailwind.md
index 38ce8221b6..0fa9afce73 100644
--- a/.context/explorations/stylex-vs-tailwind.md
+++ b/.context/explorations/stylex-vs-tailwind.md
@@ -87,6 +87,141 @@ Sources: [StyleX Official Docs](https://stylexjs.com/docs/learn/), [BetterStack
---
+## Complex Selectors: StyleX vs Tailwind
+
+### The Problem
+
+Parent-child state relationships are common:
+- Show delete button when list item is hovered
+- Change icon color when card is focused
+- Reveal actions when row is selected
+
+### Tailwind: Simple with `group-*`
+
+Tailwind has first-class support via the `group` pattern:
+
+```html
+<div class="group">
+ <h3>Item Title</h3>
+ <button class="opacity-0 group-hover:opacity-100 transition-opacity">
+ Delete
+ </button>
+</div>
+```
+
+That's it. One `group` class on parent, `group-hover:*` on children. No extra setup.
+
+**Nested groups**:
+```html
+<div class="group/card">
+ <div class="group/actions">
+ <button class="group-hover/card:opacity-50 group-hover/actions:opacity-100">
+ Edit
+ </button>
+ </div>
+</div>
+```
+
+### StyleX: CSS Variables Pattern
+
+StyleX doesn't support descendant selectors. The workaround uses CSS variables:
+
+**Step 1: Define variables**
+```typescript
+// tokens.stylex.ts
+export const parentState = stylex.defineVars({
+ childOpacity: '0',
+});
+```
+
+**Step 2: Parent sets values on hover**
+```typescript
+const styles = stylex.create({
+ card: {
+ [parentState.childOpacity]: {
+ default: '0',
+ ':hover': '1',
+ },
+ },
+});
+```
+
+**Step 3: Child reads variables**
+```typescript
+const styles = stylex.create({
+ button: {
+ opacity: parentState.childOpacity,
+ transition: 'opacity 0.2s',
+ },
+});
+```
+
+### Ergonomics Comparison
+
+| Aspect | Tailwind | StyleX |
+|--------|----------|--------|
+| **Lines of code** | 2 classes | 3 files, ~15 lines |
+| **Setup required** | None | Define variables first |
+| **Readability** | `group-hover:opacity-100` is self-explanatory | Variable indirection |
+| **Nested groups** | `group/name` naming | Multiple variable sets |
+| **Learning curve** | Intuitive | Requires understanding pattern |
+
+**Tailwind wins on ergonomics** for this use case.
+
+### Why StyleX Chose This Approach
+
+| StyleX Principle | Benefit | Cost |
+|------------------|---------|------|
+| **Explicit relationships** | Child opts into parent observation | More verbose |
+| **No "styles at a distance"** | Easier to trace where styles come from | Setup overhead |
+| **Encapsulation** | Child controls what it reads | Indirection |
+| **Static analysis** | All styles traceable at build time | No dynamic selectors |
+
+From StyleX docs: "All styles on an element should be caused by class names on that element itself."
+
+### Performance: Both Are Pure CSS
+
+Both approaches are CSS-only — no JavaScript re-renders:
+- Tailwind: Browser applies `:hover` styles via generated classes
+- StyleX: Browser updates CSS variable, children read via `var()`
+
+No `useState`, no event handlers, no re-renders in either case.
+
+### What This Means for XDS
+
+This is a real ergonomics gap with StyleX. Options:
+
+**Option 1: Accept the verbosity**
+- The pattern works, it's just more setup
+- Document it well, provide helpers
+
+**Option 2: Build abstractions**
+```typescript
+// Potential helper in @xds/variants
+const { parent, child } = createStateRelationship('listItem', {
+ actionOpacity: { default: '0', ':hover': '1' },
+});
+
+// Parent
+<div {...stylex.props(parent.container)}>
+
+// Child
+<button {...stylex.props(child.action)}>
+```
+
+**Option 3: Use Tailwind for layout, StyleX for components**
+- Components use StyleX (encapsulation)
+- Page layouts can use Tailwind (ergonomics)
+- The Tailwind preset makes tokens consistent
+
+### Recommendation
+
+Document the CSS variables pattern clearly and consider building a helper abstraction. The verbosity is the cost of StyleX's encapsulation guarantees — worth it for a component library, but should be as painless as possible.
+
+Source: [StyleX: Variables for Descendant Styles](https://stylexjs.com/docs/learn/recipes/descendant-styles/)
+
+---
+
## Tailwind v4 Deep Dive
### How Theming Works
@@ -334,6 +469,535 @@ Given the tension between StyleX's enforcement and Tailwind's ecosystem:
---
+## Variant Management Tools: tw-classed, CVA, and Tailwind Variants
+
+### The Problem These Solve
+
+When using Tailwind, components need to manage variants (sizes, intents, states) while staying DRY. Options include:
+- Manual string concatenation: `className={isLarge ? 'px-8 py-4' : 'px-4 py-2'}` (messy at scale)
+- Wrapper libraries that provide type-safe variant APIs
+
+### Three Popular Options
+
+| Tool | Description | Bundle Size | Key Features |
+|------|-------------|-------------|--------------|
+| **tw-classed** | Tailwind + CSS-in-JS DX | ~0kb | Type-safe, variants, compounds, defaults |
+| **CVA** | Class Variance Authority | Small | Framework-agnostic, simple API |
+| **Tailwind Variants** | Official variant management | Small | Slots, responsive variants, conflict resolution |
+
+### tw-classed Deep Dive
+
+**What It Is**: "Make your Tailwind components re-usable" with "Tailwind CSS and CSS-in-JS, the best of both worlds."
+
+**Core API**:
+```typescript
+import { classed } from 'tw-classed';
+
+const Button = classed('button', {
+ variants: {
+ intent: {
+ primary: 'bg-blue-500 text-white',
+ secondary: 'bg-gray-200 text-gray-900',
+ },
+ size: {
+ sm: 'text-sm px-2 py-1',
+ md: 'text-base px-4 py-2',
+ lg: 'text-lg px-6 py-3',
+ }
+ },
+ compoundVariants: [
+ {
+ intent: 'primary',
+ size: 'lg',
+ class: 'shadow-lg', // Applied when both conditions match
+ }
+ ],
+ defaultVariants: {
+ intent: 'primary',
+ size: 'md',
+ }
+});
+
+// Usage
+<Button intent="secondary" size="lg">Click me</Button>
+```
+
+**Strengths**:
+- Full TypeScript inference — `intent` prop is typed
+- Zero runtime overhead (~0kb)
+- No `forwardRef` boilerplate
+- Automatic variant autocomplete
+
+**Weaknesses**:
+- Still allows arbitrary Tailwind classes if used outside the variant system
+- No built-in slot/sub-part styling
+- Tied to Tailwind ecosystem
+
+Source: [tw-classed Official Docs](https://tw-classed.vercel.app/)
+
+### Tailwind Variants Deep Dive
+
+**What It Is**: NextUI's official variant management tool with advanced features.
+
+**Slots API** (sub-part styling):
+```typescript
+import { tv } from 'tailwind-variants';
+
+const card = tv({
+ slots: {
+ base: 'md:flex bg-slate-100 rounded-xl p-8',
+ avatar: 'w-24 h-24 md:w-48 rounded-full',
+ wrapper: 'flex-1 pt-6 md:p-8',
+ title: 'text-xl font-medium',
+ description: 'text-gray-500',
+ },
+ variants: {
+ color: {
+ primary: {
+ base: 'bg-blue-50',
+ title: 'text-blue-900',
+ },
+ secondary: {
+ base: 'bg-gray-50',
+ title: 'text-gray-900',
+ }
+ }
+ }
+});
+
+const { base, avatar, wrapper, title, description } = card({ color: 'primary' });
+
+// Usage
+<div className={base()}>
+ <img className={avatar()} />
+ <div className={wrapper()}>
+ <h3 className={title()}>...</h3>
+ <p className={description()}>...</p>
+ </div>
+</div>
+```
+
+**Strengths**:
+- **Slots enable sub-part styling** — exactly what XDS needs
+- Responsive variants
+- Compound slots (apply same classes to multiple slots)
+- Built-in conflict resolution
+- Slot-level overrides
+
+**Weaknesses**:
+- More verbose API than tw-classed
+- Requires understanding slots concept
+- Still Tailwind-dependent
+
+Source: [Tailwind Variants Slots Docs](https://www.tailwind-variants.org/docs/slots)
+
+### CVA (Class Variance Authority)
+
+**What It Is**: Framework-agnostic variant management.
+
+**Core API**:
+```typescript
+import { cva } from 'class-variance-authority';
+
+const button = cva('font-semibold rounded', {
+ variants: {
+ intent: {
+ primary: 'bg-blue-500 text-white',
+ secondary: 'bg-gray-200 text-gray-900',
+ },
+ size: {
+ sm: 'text-sm px-2 py-1',
+ md: 'text-base px-4 py-2',
+ }
+ },
+ defaultVariants: {
+ intent: 'primary',
+ size: 'md',
+ }
+});
+
+// Usage
+<button className={button({ intent: 'secondary', size: 'lg' })}>
+ Click me
+</button>
+```
+
+**Strengths**:
+- Framework-agnostic (works with any CSS)
+- Simplest API
+- Small bundle size
+
+**Weaknesses**:
+- No slots/sub-part styling
+- No responsive variants
+- No conflict resolution
+- Not Tailwind-specific (can use any classes)
+
+Source: [CVA vs Tailwind Variants Comparison](https://dev.to/webdevlapani/cva-vs-tailwind-variants-choosing-the-right-tool-for-your-design-system-12am)
+
+### How Variant Tools Affect XDS Architecture
+
+**Alignment with Zero-Styling Goals**:
+
+| Requirement | tw-classed | Tailwind Variants | CVA | StyleX |
+|-------------|-----------|-------------------|-----|--------|
+| Type-safe props | ✅ | ✅ | ✅ | ✅ |
+| Sub-part styling (slots) | ❌ | ✅ | ❌ | ✅ |
+| Arbitrary value prevention | ⚠️ Partial | ⚠️ Partial | ⚠️ Partial | ✅ Full |
+| Intent-based API | ✅ | ✅ | ✅ | ✅ |
+| Theme token integration | ⚠️ Via Tailwind | ⚠️ Via Tailwind | ⚠️ Manual | ✅ Native |
+| Evolution safety | ❌ Classes are public | ❌ Classes are public | ❌ Classes are public | ✅ Internal tokens |
+
+### The Slot Problem
+
+XDS needs sub-part styling (icon slots, label slots, etc.). Only **Tailwind Variants** and **StyleX** support this natively.
+
+### The Arbitrary Value Problem
+
+All Tailwind-based tools (tw-classed, Tailwind Variants, CVA with Tailwind) **still allow arbitrary values**:
+
+```typescript
+// All of these would work even with variant tools
+<Button className="mt-[13px]" />
+<Button className="bg-[#ff0000]" />
+```
+
+Only StyleX prevents this at compile time through TypeScript.
+
+### Option 5: Tailwind Variants + Strict Linting
+
+Use Tailwind Variants for ergonomics and slots, but add strict safeguards:
+
+1. **Tailwind Variants for component definition** — slots + variants
+2. **Constrained theme via `@theme`** — only allowed tokens exist
+3. **Lint to prevent arbitrary values** — build-time enforcement
+4. **TypeScript wrapper to hide class strings** — components expose props, not className
+
+**Pros**:
+- Slots for sub-part styling (like XDS theming proposal)
+- Tailwind ecosystem compatibility
+- Type-safe variant API
+- Familiar to developers and AI
+
+**Cons**:
+- Enforcement still relies on lint rules (not compile-time)
+- Can't prevent all arbitrary value leakage
+- Theme tokens are public CSS variables
+
+---
+
+## Achieving tw-classed Ergonomics Without Exposed CSS Classes
+
+### The Challenge
+
+tw-classed provides excellent variant API ergonomics:
+```typescript
+const Button = classed('button', {
+ variants: { intent: { primary: '...' } }
+});
+```
+
+But it has a fundamental constraint issue: **CSS classes are public**. Consumers can:
+- Bypass the variant API with `className` overrides
+- Depend on generated class names (coupling)
+- Use arbitrary Tailwind values
+
+Can we get the ergonomics without the exposed classes?
+
+### Option A: StyleX + Variant Wrapper (Recommended)
+
+Build a variant API wrapper around StyleX that mimics tw-classed ergonomics but maintains enforcement.
+
+**Core implementation**:
+```typescript
+// @xds/variants — Internal wrapper around StyleX
+import * as stylex from '@stylexjs/stylex';
+
+export function createVariants(config) {
+ const { base, slots = {}, variants, compoundVariants = [], defaultVariants } = config;
+
+ return function(variantProps) {
+ // Compute which styles to apply based on variant selection
+ const appliedVariants = Object.entries(variantProps).map(([key, value]) => {
+ return variants[key]?.[value];
+ });
+
+ // Apply compound variants
+ const appliedCompounds = compoundVariants
+ .filter(cv => {
+ return Object.entries(cv).every(([key, value]) => {
+ if (key === 'style') return true; // Skip the style key
+ return variantProps[key] === value;
+ });
+ })
+ .map(cv => cv.style);
+
+ return {
+ base: () => stylex.props(base, ...appliedVariants, ...appliedCompounds),
+ slots: Object.fromEntries(
+ Object.entries(slots).map(([name, slotStyles]) => [
+ name,
+ () => stylex.props(slotStyles)
+ ])
+ ),
+ };
+ };
+}
+```
+
+**Usage**:
+```typescript
+// Component definition
+import { createVariants } from '@xds/variants';
+import * as stylex from '@stylexjs/stylex';
+
+const button = createVariants({
+ base: stylex.create({
+ root: {
+ padding: 8,
+ borderRadius: 4,
+ cursor: 'pointer',
+ }
+ }).root,
+
+ slots: {
+ icon: stylex.create({
+ root: { width: 16, height: 16, marginRight: 8 }
+ }).root,
+ label: stylex.create({
+ root: { fontWeight: 500 }
+ }).root,
+ },
+
+ variants: {
+ intent: {
+ primary: stylex.create({
+ root: {
+ backgroundColor: 'var(--xds-color-primary)',
+ color: 'var(--xds-color-on-primary)',
+ }
+ }).root,
+ secondary: stylex.create({
+ root: {
+ backgroundColor: 'var(--xds-color-secondary)',
+ color: 'var(--xds-color-on-secondary)',
+ }
+ }).root,
+ },
+ size: {
+ sm: stylex.create({
+ root: { fontSize: 14, padding: 4 }
+ }).root,
+ md: stylex.create({
+ root: { fontSize: 16, padding: 8 }
+ }).root,
+ lg: stylex.create({
+ root: { fontSize: 18, padding: 12 }
+ }).root,
+ }
+ },
+
+ compoundVariants: [
+ {
+ intent: 'primary',
+ size: 'lg',
+ style: stylex.create({
+ root: { boxShadow: '0 4px 6px rgba(0,0,0,0.1)' }
+ }).root,
+ }
+ ],
+
+ defaultVariants: {
+ intent: 'primary',
+ size: 'md',
+ }
+});
+
+// Component using the variant system
+export function Button({ intent = 'primary', size = 'md', icon, children }) {
+ const styles = button({ intent, size });
+
+ return (
+ <button {...styles.base()}>
+ {icon && <span {...styles.slots.icon()}>{icon}</span>}
+ <span {...styles.slots.label()}>{children}</span>
+ </button>
+ );
+}
+```
+
+**What this achieves**:
+- ✅ tw-classed-like variant API
+- ✅ Slot-based sub-part styling
+- ✅ Compound variants
+- ✅ Default variants
+- ✅ **No exposed CSS classes** — consumers only see props
+- ✅ TypeScript inference for variant values
+- ✅ Compile-time enforcement via StyleX
+
+**Type inference**:
+```typescript
+type ButtonVariants = {
+ intent: 'primary' | 'secondary';
+ size: 'sm' | 'md' | 'lg';
+};
+
+// Inferred from variant definition
+type ButtonProps = ButtonVariants & { children: ReactNode; icon?: ReactNode };
+```
+
+**Tradeoffs**:
+| Benefit | Drawback |
+|---------|----------|
+| Zero CSS class exposure | More verbose than tw-classed (JS objects vs strings) |
+| Full compile-time enforcement | Requires custom wrapper (not off-the-shelf) |
+| StyleX bundle benefits | Team needs to learn StyleX |
+| Sub-part styling native | More complex implementation |
+
+### Option B: Tokenami
+
+[Tokenami](https://github.com/tokenami/tokenami) is a design token system that generates **typed CSS properties** instead of classes.
+
+**How it works**:
+```typescript
+import { css } from '@tokenami/css';
+
+// Define tokens
+const tokens = {
+ color: {
+ primary: '#0066cc',
+ secondary: '#6b7280',
+ },
+ spacing: {
+ sm: '0.5rem',
+ md: '1rem',
+ }
+};
+
+// Usage — CSS properties, not classes
+<button
+ style={css({
+ backgroundColor: 'var(--color-primary)',
+ padding: 'var(--spacing-md)',
+ })}
+>
+ Click me
+</button>
+```
+
+**Variant wrapper**:
+```typescript
+const button = createTokenamiVariants({
+ variants: {
+ intent: {
+ primary: { backgroundColor: 'var(--color-primary)' },
+ secondary: { backgroundColor: 'var(--color-secondary)' },
+ }
+ }
+});
+
+// No classes generated — only CSS variables
+```
+
+**Tradeoffs**:
+| Benefit | Drawback |
+|---------|----------|
+| No CSS classes at all | Less mature ecosystem |
+| Token-first architecture | Different mental model |
+| Type-safe CSS properties | Verbose inline styles |
+
+**Verdict**: Interesting but immature. Not worth the risk for XDS core.
+
+### Option C: Tailwind Variants Internal, Props-Only Public
+
+Use Tailwind Variants internally but hide classes from consumers.
+
+**Implementation**:
+```typescript
+import { tv } from 'tailwind-variants';
+
+// Internal variant definition (not exported)
+const buttonVariants = tv({
+ slots: {
+ base: 'rounded cursor-pointer',
+ icon: 'w-4 h-4 mr-2',
+ label: 'font-medium',
+ },
+ variants: {
+ intent: {
+ primary: {
+ base: 'bg-primary text-on-primary',
+ },
+ secondary: {
+ base: 'bg-secondary text-on-secondary',
+ }
+ }
+ }
+});
+
+// Public component — props only
+export function Button({ intent = 'primary', size = 'md', icon, children }) {
+ const styles = buttonVariants({ intent, size });
+
+ return (
+ <button className={styles.base()}>
+ {icon && <span className={styles.slots.icon()}>{icon}</span>}
+ <span className={styles.slots.label()}>{children}</span>
+ </button>
+ );
+}
+
+// className prop not exposed — no escape hatch
+```
+
+**Enforcement strategy**:
+1. Don't expose `className` prop on components
+2. Internal Tailwind Variants definition
+3. Lint rules to prevent `className` on XDS components
+4. TypeScript types enforce props-only API
+
+**Tradeoffs**:
+| Benefit | Drawback |
+|---------|----------|
+| Uses mature Tailwind Variants | Classes still exist in DOM (inspectable) |
+| Slots for sub-parts | Can't prevent consumers from finding class names |
+| Tailwind ecosystem compatible | Arbitrary values still possible in internal code |
+| Simpler implementation | Enforcement relies on conventions, not compiler |
+
+**Key weakness**: Classes are in the DOM. Savvy consumers can inspect and depend on them.
+
+### Comparison
+
+| Approach | Enforcement Level | Ergonomics | Maturity | Recommendation |
+|----------|------------------|------------|----------|----------------|
+| **StyleX + Variant Wrapper** | ✅ Compile-time | ⚠️ Verbose | ✅ Proven (StyleX) | **Best for XDS** |
+| **Tokenami** | ✅ No classes | ⚠️ Different model | ❌ Immature | Too risky |
+| **Tailwind Variants (hidden)** | ⚠️ Convention-based | ✅ Simple | ✅ Proven | Classes leak to DOM |
+
+### Recommendation: Option A
+
+**Build `@xds/variants` as a lightweight wrapper around StyleX** that provides:
+- tw-classed-like API ergonomics
+- Slot-based sub-part styling
+- Compound variants
+- Default variants
+- Full compile-time enforcement
+- Zero CSS class exposure
+
+This combines:
+- The ergonomics benefit of variant tools
+- The enforcement guarantees of StyleX
+- The evolution safety of encapsulated tokens
+- The AI compatibility of typed props
+
+**Implementation plan**:
+1. Create `@xds/variants` package
+2. Build `createVariants()` wrapper around StyleX
+3. Use it for all core components
+4. Document migration from tw-classed for adopters
+
+---
+
## Recommendation
Given zero-styling architecture requirements:
@@ -345,34 +1009,208 @@ Given zero-styling architecture requirements:
| Theming architecture | **StyleX** | Scoped themes are first-class |
| Ergonomics | **Tailwind** | Concise class syntax |
| Ecosystem pressure | **Tailwind** | More AI UIs, more templates |
+| No class exposure | **StyleX** | Classes are implementation detail |
-### Proposed Path: Option 4 (StyleX Core + Tailwind Interop)
+### Proposed Path: StyleX + Variant Wrapper + Tailwind Interop
-1. **StyleX for core constraint layer**
- - Zero-styling architecture depends on enforcement
- - Type-safe theming with scoped overrides
+Combines the best of all approaches:
-2. **Export theme tokens as CSS variables**
- - `--xds-color-primary`, `--xds-spacing-sm`, etc.
- - Consumable by any CSS solution
+**1. `@xds/variants` wrapper around StyleX**
+- tw-classed-like ergonomics for component authors
+- Slots for sub-part styling
+- Compound variants, default variants
+- Full compile-time enforcement
+- Zero CSS class exposure to consumers
-3. **Provide Tailwind preset**
- ```css
- @theme {
- --color-primary: var(--xds-color-primary);
- --spacing-sm: var(--xds-spacing-sm);
- }
- ```
- - Tailwind users get XDS tokens as utilities
+**2. StyleX for core constraint layer**
+- Zero-styling architecture depends on enforcement
+- Type-safe theming with scoped overrides
+- Classes are atomic and opaque (not semantic)
-4. **Document migration path**
- - Tailwind → XDS for teams wanting stricter enforcement
- - XDS → Tailwind for prototyping flexibility
+**3. Export theme tokens as CSS variables (semantic tier only)**
+- `--xds-color-primary`, `--xds-spacing-sm`, etc.
+- Available for swizzled components
+- Base/primitive tokens not exposed
+
+**4. Provide Tailwind preset for ecosystem compatibility**
+```css
+@theme {
+ --color-primary: var(--xds-color-primary);
+ --spacing-sm: var(--xds-spacing-sm);
+}
+```
+- Tailwind users get XDS tokens as utilities
+- Interop without compromising core enforcement
+
+**5. Document migration path**
+- tw-classed → @xds/variants for adopters
+- Tailwind → XDS for teams wanting stricter enforcement
This gives:
-- Strict enforcement internally (StyleX)
-- Compatibility externally (Tailwind consumers use same tokens)
-- AI-friendly surface (Tailwind utilities map to constrained tokens)
+- **Strict enforcement internally** (StyleX + types)
+- **Ergonomic authoring** (@xds/variants API)
+- **No class exposure** (props-only public API)
+- **Compatibility externally** (Tailwind preset uses same tokens)
+- **AI-friendly surface** (typed props, constrained tokens)
+
+---
+
+## AI Considerations for StyleX + Variants Approach
+
+### The Author vs Consumer Gap
+
+The "AI gap" with StyleX is primarily for **component authors**, not **component consumers**.
+
+| Role | API Surface | AI Difficulty |
+|------|-------------|---------------|
+| **Consumer** | `<Button intent="primary" size="md">` | Trivial — typed props, autocomplete |
+| **Author** | `createVariants({ ... stylex.create() ... })` | Higher — unfamiliar StyleX patterns |
+| **Swizzler** | Semantic CSS variables + custom StyleX | Medium — documented patterns |
+
+**Why this matters**: Since XDS ships pre-built components, most users are consumers. They never touch StyleX — they just use typed props, which is extremely AI-friendly.
+
+**For component authors** (XDS maintainers or contributors):
+- StyleX is less common in training data than Tailwind
+- LLMs may hallucinate incorrect StyleX APIs
+- TypeScript catches errors immediately → fast iteration
+- Codebase context teaches patterns quickly
+
+### Type Inference for Variants
+
+`@xds/variants` needs tw-classed-style type inference:
+
+```typescript
+// The goal: infer variant types from definition
+const button = createVariants({
+ variants: {
+ intent: {
+ primary: stylex.create({...}).root,
+ secondary: stylex.create({...}).root,
+ },
+ size: {
+ sm: stylex.create({...}).root,
+ md: stylex.create({...}).root,
+ }
+ }
+});
+
+// TypeScript infers:
+// { intent: 'primary' | 'secondary', size: 'sm' | 'md' }
+type ButtonVariants = Parameters<typeof button>[0];
+```
+
+**Implementation approach**:
+```typescript
+function createVariants<
+ TVariants extends Record<string, Record<string, StyleXStyles>>
+>(config: {
+ base?: StyleXStyles;
+ variants: TVariants;
+ defaultVariants?: Partial<VariantProps<TVariants>>;
+}): VariantFunction<TVariants>;
+
+type VariantProps<T> = {
+ [K in keyof T]: keyof T[K]
+};
+```
+
+This gives the same strong typing as tw-classed — variants only match the defined set.
+
+### Distributable Themes Tradeoff
+
+When themes are separate packages, there's tension between type safety and AI context:
+
+```
+@company/dark-theme @xds/core
+├── theme.ts ├── Button.tsx
+│ intents: { │ intent: ???
+│ primary, │ // What intents are valid?
+│ secondary │ // Component doesn't know
+│ } │
+```
+
+**Three approaches**:
+
+| Approach | Type Safety | AI Context Required | AI Difficulty |
+|----------|-------------|---------------------|---------------|
+| **Generic components** | ✅ Full | Theme type in scope | Medium — needs to understand generics |
+| **Superset intents** | ⚠️ Runtime | Just component | Low — simple props |
+| **Codegen** | ✅ Full | Generated component | Low — types are concrete |
+
+**Recommended pattern: Re-export with concrete types**
+
+```typescript
+// src/components/index.ts — App-level typed components
+import { Button as XDSButton } from '@xds/core';
+import { theme } from '@company/dark-theme';
+
+// Re-export with concrete types
+export const Button = XDSButton<typeof theme>;
+// Now intent is concretely typed: 'primary' | 'secondary'
+```
+
+This gives AI a single file with concrete types — no need to reason about generics or cross-package relationships.
+
+### Swizzle API Vibe-ability
+
+The swizzle API must also be AI-friendly. When users swizzle a component, AI needs to help them customize it.
+
+**What swizzlers have access to**:
+- Semantic CSS variables: `var(--xds-color-primary)`
+- The original StyleX code to modify
+- Documented patterns for common customizations
+
+**Making swizzle AI-friendly**:
+
+| Strategy | How It Helps |
+|----------|--------------|
+| **Consistent variable naming** | `--xds-{category}-{name}` is predictable |
+| **JSDoc on swizzled code** | Inline documentation for the code AI will read |
+| **Example customizations** | Common patterns in the swizzled file |
+| **Simple entry points** | Clear "this is where you customize" markers |
+
+**Swizzle template structure**:
+```typescript
+// Button.tsx (swizzled)
+/**
+ * Swizzled Button component.
+ *
+ * Available semantic tokens:
+ * - --xds-color-primary, --xds-color-secondary, etc.
+ * - --xds-spacing-sm, --xds-spacing-md, etc.
+ *
+ * Common customizations:
+ * - Add new intent: add to `variants.intent`
+ * - Change sizing: modify `variants.size`
+ * - Add animation: add to base styles
+ */
+
+const button = createVariants({
+ // 👇 CUSTOMIZE: Base styles applied to all variants
+ base: stylex.create({
+ root: { /* ... */ }
+ }).root,
+
+ // 👇 CUSTOMIZE: Add or modify intents here
+ variants: {
+ intent: {
+ primary: stylex.create({
+ root: { backgroundColor: 'var(--xds-color-primary)' }
+ }).root,
+ // Add custom intents below:
+ }
+ }
+});
+```
+
+**The key insight**: Swizzled code is essentially "AI context" — structure it so LLMs can read and modify it effectively.
+
+| Swizzle Design Choice | AI Impact |
+|-----------------------|-----------|
+| Comments marking customization points | Guides where to edit |
+| Semantic variables (not raw values) | Predictable, learnable |
+| Flat structure (not deeply nested) | Easier to navigate |
+| TypeScript types on everything | Catches errors immediately |
---
@@ -452,6 +1290,30 @@ The swizzle API provides a middle ground that actually *reduces* unnecessary com
## Open Questions
+### @xds/variants Implementation
+- How do we type-infer variant props from the `createVariants` definition?
+- Should variants be defined per-component or centralized in theme?
+- How does the variant wrapper integrate with theme context?
+- Should responsive variants be part of the API or handled separately?
+
+### Complex Selectors / Parent-Child State
+- Should we build a `createStateRelationship()` helper to reduce CSS variable boilerplate?
+- Is the ergonomics gap with Tailwind's `group-hover:*` acceptable for XDS?
+- Should XDS components have built-in state variables for common patterns (hover reveal, focus highlight)?
+- Could we generate the variable definitions automatically from component slots?
+
+### Distributable Themes
+- Generic components vs superset intents vs codegen — which approach for multi-theme type safety?
+- How do we make the re-export pattern discoverable for users?
+- Should XDS provide a CLI to generate typed component re-exports from a theme?
+- How do we handle theme switching at runtime while maintaining type safety?
+
+### Swizzle API
+- What's the right level of inline documentation for swizzled components?
+- Should swizzled components include example customizations as comments?
+- How do we version swizzled component templates separately from the main library?
+
+### Token and Theming
- How do we lint/prevent arbitrary Tailwind values in consumer codebases?
- Should the Tailwind preset be opt-in or default?
- Can we generate Tailwind classes from StyleX definitions automatically?
diff --git a/.context/explorations/swizzle-layer-ergonomics.md b/.context/explorations/swizzle-layer-ergonomics.md
new file mode 100644
index 0000000000..7d7959f030
--- /dev/null
+++ b/.context/explorations/swizzle-layer-ergonomics.md
@@ -0,0 +1,522 @@
+# Swizzle Layer Ergonomics
+
+*Exploration — January 2026*
+
+## Context
+
+The swizzle layer has competing tensions:
+- **Close to core** (StyleX, XDS patterns) → easy contributions, shared utilities
+- **Close to builder** (Tailwind, familiar patterns) → AI can help, team can maintain
+
+## Decision Criteria (from product discussions)
+
+| Question | Answer | Implication |
+|----------|--------|-------------|
+| Is contribution back to core important? | Yes, but **unblocking builders is more important** | Optimize for builder ergonomics first |
+| What gets swizzled? | Most swizzled content is **use-case dependent** | Won't flow back to core anyway |
+| Small tweaks or structural changes? | **Two camps**: DS teams (heavy customization) + Regular builders (functionality > styling) | Need to serve both personas |
+| Is AI assistance critical? | **Yes** — common workflow to unblock builders | Must be AI-friendly |
+| Can we invest in tooling/docs? | **Absolutely** | Can build abstractions to bridge the gap |
+
+## Personas Using Swizzle
+
+### Persona 1: Design System Team
+
+**Who**: Designers/engineers maintaining company design system
+**Goal**: Customize components to match brand guidelines
+**Skill level**: High — willing to learn StyleX
+**Swizzle use**: Heavy customization, styling-focused
+
+**Example needs**:
+- Custom button intents matching brand hierarchy
+- Specific spacing/sizing variants
+- Custom animations/transitions
+- Brand-specific slots (e.g., badge on buttons)
+
+### Persona 2: Regular Builder
+
+**Who**: Product engineers shipping features
+**Goal**: Unblock a specific functionality need
+**Skill level**: Medium — wants to ship fast
+**Swizzle use**: Functionality-focused, minimal styling changes
+
+**Example needs**:
+- Add click tracking to button
+- Custom validation logic in input
+- Different keyboard navigation behavior
+- Integration with non-XDS libraries
+
+## Proposed Architecture: Dual-Path Swizzle
+
+```
+┌─────────────────────────────────────────────────────────────────┐
+│ SWIZZLE PATH A: STYLING CUSTOMIZATION │
+│ Target: DS teams, styling-focused │
+│ │
+│ npx xds customize Button --theme=myTheme │
+│ → Generates theme extension (AI-friendly) │
+│ │
+│ Format: Theme config (JSON-like) │
+│ AI vibes: ✅ High (structured data) │
+│ Contribution back: ✅ Possible (just config) │
+├─────────────────────────────────────────────────────────────────┤
+│ SWIZZLE PATH B: FUNCTIONAL OVERRIDE │
+│ Target: Regular builders, functionality-focused │
+│ │
+│ npx xds swizzle Button │
+│ → Copies component source with AI-friendly annotations │
+│ │
+│ Format: Full source (StyleX + detailed comments) │
+│ AI vibes: ⚠️ Medium (unfamiliar but documented) │
+│ Contribution back: ❌ Unlikely (too use-case specific) │
+└─────────────────────────────────────────────────────────────────┘
+```
+
+### Path A: Styling Customization (Theme Extension)
+
+For DS teams that want to customize appearance without changing structure.
+
+**Command**:
+```bash
+npx xds customize Button --theme=corporate
+```
+
+**Generated file** (`themes/corporate/button.ts`):
+```typescript
+// Auto-generated by XDS customize
+// AI-friendly format: structured config, not code
+
+import { extendTheme } from '@xds/core';
+
+export const corporateButtonTheme = extendTheme({
+ component: 'button',
+
+ // Add new intents
+ intents: {
+ 'brand-primary': {
+ background: '--corporate-blue',
+ color: 'white',
+ hoverBackground: '--corporate-blue-dark',
+ },
+ 'brand-secondary': {
+ background: '--corporate-gray',
+ color: '--corporate-blue',
+ }
+ },
+
+ // Modify existing sizes
+ sizes: {
+ lg: {
+ padding: '16px 32px', // Override default
+ fontSize: '18px',
+ }
+ },
+
+ // Customize slots
+ slots: {
+ icon: {
+ marginRight: '12px', // Override default
+ }
+ }
+});
+```
+
+**Why this is AI-friendly**:
+- Structured config format (AI can generate JSON-like structures easily)
+- Clear property names (`background`, `color`, `padding`)
+- No StyleX syntax to learn
+- Predictable schema
+
+**Usage**:
+```tsx
+import { XDSProvider } from '@xds/core';
+import { corporateButtonTheme } from './themes/corporate/button';
+
+<XDSProvider theme={corporateButtonTheme}>
+ <Button intent="brand-primary">Corporate CTA</Button>
+</XDSProvider>
+```
+
+### Path B: Functional Override (Full Swizzle)
+
+For builders who need to change behavior or structure.
+
+**Command**:
+```bash
+npx xds swizzle Button
+```
+
+**Generated file** (`components/xds/Button/Button.tsx`):
+```typescript
+/**
+ * 🎨 SWIZZLED COMPONENT: Button
+ *
+ * Source: @xds/[email protected]
+ * Swizzled: 2026-01-09
+ *
+ * ⚠️ This component is now your responsibility.
+ * Changes here won't receive automatic updates from XDS.
+ *
+ * COMMON CUSTOMIZATIONS:
+ *
+ * 1. Add custom behavior:
+ * - Add onClick tracking: see line 45
+ * - Add loading state: see line 52
+ * - Custom keyboard handling: see line 67
+ *
+ * 2. Modify structure:
+ * - Add new slots: see line 89
+ * - Change DOM structure: see line 102
+ *
+ * 3. Styling changes:
+ * - Use semantic tokens: var(--xds-color-primary)
+ * - Available tokens documented at line 15
+ */
+
+import * as stylex from '@stylexjs/stylex';
+import { createVariants } from '@xds/variants';
+
+// 👇 AVAILABLE SEMANTIC TOKENS
+// Colors: --xds-color-primary, --xds-color-secondary, --xds-color-danger
+// Spacing: --xds-spacing-sm, --xds-spacing-md, --xds-spacing-lg
+// Typography: --xds-font-button, --xds-font-weight-medium
+
+const button = createVariants({
+ // 👇 CUSTOMIZE: Base styles applied to all variants
+ base: stylex.create({
+ root: {
+ cursor: 'pointer',
+ borderRadius: 4,
+ transition: 'all 0.2s',
+ // Add custom styles here:
+ }
+ }).root,
+
+ slots: {
+ // 👇 CUSTOMIZE: Icon slot
+ icon: stylex.create({
+ root: { width: 16, height: 16, marginRight: 8 }
+ }).root,
+
+ // 👇 CUSTOMIZE: Label slot
+ label: stylex.create({
+ root: { fontWeight: 500 }
+ }).root,
+ },
+
+ variants: {
+ intent: {
+ // 👇 CUSTOMIZE: Add or modify intents
+ primary: stylex.create({
+ root: {
+ backgroundColor: 'var(--xds-color-primary)',
+ color: 'var(--xds-color-on-primary)',
+ }
+ }).root,
+ }
+ },
+});
+
+interface ButtonProps {
+ intent?: 'primary' | 'secondary';
+ children: React.ReactNode;
+ onClick?: () => void;
+ // 👇 CUSTOMIZE: Add new props here
+}
+
+export function Button({ intent = 'primary', children, onClick }: ButtonProps) {
+ const styles = button({ intent });
+
+ // 👇 CUSTOMIZE: Add custom behavior (tracking, analytics, etc.)
+ const handleClick = () => {
+ // Example: Add analytics
+ // analytics.track('button_clicked', { intent });
+ onClick?.();
+ };
+
+ return (
+ <button {...stylex.props(styles.base())} onClick={handleClick}>
+ {/* 👇 CUSTOMIZE: Modify structure, add slots */}
+ <span {...stylex.props(styles.slots.label())}>
+ {children}
+ </span>
+ </button>
+ );
+}
+```
+
+**Why this works for AI despite StyleX**:
+1. **Extensive inline documentation** — AI reads comments
+2. **Clear customization points** — 👇 CUSTOMIZE markers
+3. **Examples in comments** — "Add onClick tracking: see line 45"
+4. **Semantic tokens only** — no raw StyleX internals exposed
+5. **Flat structure** — not deeply nested
+
+**The pattern**: Swizzled code is essentially AI context. Structure it so LLMs know exactly where and how to modify.
+
+---
+
+## Implementation Plan
+
+### Phase 1: Path A (Theme Extension)
+
+**Build**: `npx xds customize` command
+- Generates theme extension config files
+- JSON-like structure, AI-friendly
+- Type-safe with theme validation
+
+**DX improvements**:
+- `npx xds customize Button --interactive` — CLI prompts
+- Auto-generates TypeScript types from config
+- Preview in Storybook
+
+### Phase 2: Path B (Functional Swizzle)
+
+**Build**: Enhanced swizzle templates
+- Heavy inline documentation
+- Clear customization markers
+- Example modifications in comments
+- Semantic tokens only (no raw StyleX internals)
+
+**AI assistance**:
+- Templates designed as "AI context"
+- Common modifications documented inline
+- Codebase examples in comments
+
+### Phase 3: AI Tooling
+
+**Build**: AI-specific helpers
+- `npx xds customize Button --with-ai-context` — generates extra context file
+- `.xds/ai-context.md` — component customization guide for AI
+- Cursor/Claude rules for XDS patterns
+
+---
+
+## Tailwind Ergonomics Option
+
+For builders who prefer Tailwind patterns, we can offer a Tailwind-flavored swizzle that still uses XDS tokens.
+
+### Path A with Tailwind Syntax
+
+**Command**:
+```bash
+npx xds customize Button --theme=corporate --format=tailwind
+```
+
+**Generated file** (`themes/corporate/button.config.ts`):
+```typescript
+// Tailwind-style config format — AI-friendly, familiar to most builders
+import { defineButtonTheme } from '@xds/core';
+
+export const corporateButton = defineButtonTheme({
+ intents: {
+ 'brand-primary': {
+ base: 'bg-primary text-on-primary rounded-md',
+ hover: 'hover:bg-primary-dark',
+ focus: 'focus:ring-2 focus:ring-primary/50',
+ disabled: 'disabled:opacity-50 disabled:cursor-not-allowed',
+ },
+ 'brand-secondary': {
+ base: 'bg-secondary text-on-secondary rounded-md border border-border',
+ hover: 'hover:bg-secondary-dark',
+ },
+ },
+
+ sizes: {
+ sm: 'px-3 py-1.5 text-sm',
+ md: 'px-4 py-2 text-base',
+ lg: 'px-6 py-3 text-lg',
+ },
+});
+```
+
+**Key point**: The Tailwind classes use XDS token names (`bg-primary`, `text-on-primary`) from the Tailwind preset, not arbitrary values.
+
+**Why this works**:
+- Familiar Tailwind syntax
+- AI can generate this confidently
+- Still uses XDS tokens (consistency)
+- Linting prevents arbitrary values
+
+### Path B with Tailwind Variants
+
+**Command**:
+```bash
+npx xds swizzle Button --format=tailwind
+```
+
+**Generated file** (`components/xds/Button.tsx`):
+```tsx
+/**
+ * 🎨 SWIZZLED COMPONENT: Button
+ *
+ * Format: Tailwind Variants (familiar to most builders)
+ * Tokens: XDS theme tokens (via Tailwind preset)
+ *
+ * RULES:
+ * ✅ Use XDS token classes: bg-primary, text-on-primary, p-md
+ * ❌ No arbitrary values: bg-[#ff0000], mt-[13px]
+ */
+
+import { tv } from 'tailwind-variants';
+
+const button = tv({
+ base: 'rounded-md cursor-pointer transition-colors',
+
+ slots: {
+ icon: 'w-4 h-4',
+ label: 'font-medium',
+ },
+
+ variants: {
+ intent: {
+ primary: {
+ base: 'bg-primary text-on-primary hover:bg-primary-dark',
+ icon: 'text-on-primary',
+ },
+ secondary: {
+ base: 'bg-secondary text-on-secondary hover:bg-secondary-dark',
+ icon: 'text-on-secondary',
+ },
+ danger: {
+ base: 'bg-danger text-on-danger hover:bg-danger-dark',
+ },
+ // 👇 CUSTOMIZE: Add new intents here
+ },
+
+ size: {
+ sm: { base: 'px-sm py-xs text-sm', icon: 'w-3 h-3' },
+ md: { base: 'px-md py-sm text-base', icon: 'w-4 h-4' },
+ lg: { base: 'px-lg py-md text-lg', icon: 'w-5 h-5' },
+ },
+ },
+
+ defaultVariants: {
+ intent: 'primary',
+ size: 'md',
+ },
+});
+
+interface ButtonProps {
+ intent?: 'primary' | 'secondary' | 'danger';
+ size?: 'sm' | 'md' | 'lg';
+ children: React.ReactNode;
+ onClick?: () => void;
+ // 👇 CUSTOMIZE: Add new props
+}
+
+export function Button({ intent, size, children, onClick }: ButtonProps) {
+ const styles = button({ intent, size });
+
+ // 👇 CUSTOMIZE: Add behavior (tracking, etc.)
+ const handleClick = () => {
+ onClick?.();
+ };
+
+ return (
+ <button className={styles.base()} onClick={handleClick}>
+ <span className={styles.label()}>
+ {children}
+ </span>
+ </button>
+ );
+}
+```
+
+### Format Selection
+
+| Builder knows... | Recommended format |
+|-----------------|-------------------|
+| Tailwind | `--format=tailwind` |
+| StyleX / CSS-in-JS | `--format=stylex` (default) |
+| Neither | `--format=tailwind` (more training data) |
+
+**Command with format**:
+```bash
+# Default (StyleX)
+npx xds swizzle Button
+
+# Tailwind format
+npx xds swizzle Button --format=tailwind
+```
+
+### Constraints Still Apply
+
+Both formats enforce XDS tokens:
+
+```tsx
+// ✅ Uses XDS token (via Tailwind preset)
+base: 'bg-primary text-on-primary p-md',
+
+// ❌ Linting error: arbitrary value not allowed
+base: 'bg-[#0066cc] text-white p-4',
+```
+
+The Tailwind preset maps XDS tokens:
+- `bg-primary` → `var(--xds-color-primary)`
+- `text-on-primary` → `var(--xds-color-on-primary)`
+- `p-md` → `var(--xds-spacing-md)`
+
+### Tradeoff: Tailwind Format
+
+| Benefit | Cost |
+|---------|------|
+| Familiar syntax, AI-friendly | Classes in DOM (less encapsulation) |
+| More training data for LLMs | Can't prevent all arbitrary values |
+| Faster onboarding | Diverges from core XDS patterns |
+| Team can maintain without learning StyleX | Harder to contribute back |
+
+**Recommendation**: Offer both formats. Let builders choose based on their team's skills. Default to Tailwind for better AI vibes.
+
+---
+
+## Tradeoffs
+
+| Approach | Path A (Theme Extension) | Path B (Full Swizzle) |
+|----------|-------------------------|----------------------|
+| **Complexity** | Low | High |
+| **AI vibes** | ✅ Excellent | ⚠️ Medium |
+| **Covers use cases** | Styling only | Everything |
+| **Contribution back** | ✅ Possible | ❌ Unlikely |
+| **Maintenance** | ✅ Easy | ⚠️ Your responsibility |
+| **Learning curve** | None | StyleX required |
+
+---
+
+## Decision
+
+**Implement both paths** with clear guidance on which to use when:
+
+| Builder needs... | Recommended path |
+|-----------------|------------------|
+| Different colors/spacing | Path A (customize) |
+| New button intent | Path A (customize) |
+| Custom click tracking | Path B (swizzle) |
+| Different validation logic | Path B (swizzle) |
+| Custom keyboard behavior | Path B (swizzle) |
+| Structural changes | Path B (swizzle) |
+
+**Key insight**: Most swizzles (80%?) are styling customizations. Serve those with the simple path. The 20% who need functional changes accept the complexity.
+
+---
+
+## Open Questions
+
+- Should Path A generate Tailwind config instead of theme extension for Tailwind users?
+- Can we auto-detect which path a builder needs based on their prompt?
+- Should swizzled components include a "sync from upstream" command?
+- How do we version swizzled templates vs core components?
+
+---
+
+## Related
+
+- `stylex-vs-tailwind.md` — Complex selectors ergonomics gap
+- `xds-architecture.md` — Swizzle API section
+- `ai-design-system-gaps.md` — Why constraints beat suggestions
+
+---
+
+## Sources
+
+- [shadcn/ui Documentation](https://ui.shadcn.com/docs)
diff --git a/.context/proposals/xds-architecture.md b/.context/proposals/xds-architecture.md
new file mode 100644
index 0000000000..e1a4dbbb5a
--- /dev/null
+++ b/.context/proposals/xds-architecture.md
@@ -0,0 +1,1060 @@
+# XDS Architecture Proposal
+
+*Proposal — January 2026*
+
+## Builder Jobs To Be Done
+
+XDS serves developers across their workflow phases. Based on research in `frontend-developer-jtbd.md`:
+
+### Primary Jobs by Phase
+
+| Phase | Job | What Success Looks Like |
+|-------|-----|------------------------|
+| **Setup** | Set up project styling | Define tokens/themes in one place; immediate consistency |
+| **Setup** | Configure for my stack | Works with my build tools, framework, IDE |
+| **Build** | Construct pages from components | Compose UI quickly with typed props, autocomplete |
+| **Build** | Customize component appearance | Theme changes propagate everywhere automatically |
+| **Build** | Handle edge cases | Swizzle when needed, clear escalation path |
+| **Maintain** | Update to new versions | Clear migration path, deprecation warnings |
+| **Collaborate** | Work with AI assistants | Typed APIs, constrained options, predictable patterns |
+
+### How XDS Layers Map to Jobs
+
+| XDS Layer | Primary Jobs Served |
+|-----------|---------------------|
+| **Theme Layer** | Set up styling, customize appearance, maintain consistency |
+| **Component API** | Construct pages, stay consistent, work with AI |
+| **Swizzle Layer** | Handle edge cases, customize beyond theme |
+| **CLI/Tooling** | Configure for stack, adopt incrementally, update versions |
+
+### The Three Core Builder Actions
+
+| Job | What the Builder Wants | XDS Layer |
+|-----|------------------------|-----------|
+| **1. Set visual style** | "I want to define my project's look and feel" | **Theme Layer** |
+| **2. Override/create components** | "I want to customize beyond what's possible in the theme" | **Swizzle Layer** |
+| **3. Construct pages** | "I want to use components to build UIs" | **Component API** |
+
+```
+┌─────────────────────────────────────────────────────────────────────┐
+│ JOB 3: CONSTRUCT PAGES (Component API) │
+│ │
+│ <Button intent="primary" size="md" /> │
+│ <Stack gap="md"><Card>...</Card></Stack> │
+│ │
+│ Builder experience: │
+│ - Typed props, autocomplete-driven │
+│ - No styling decisions — just intent and structure │
+│ - AI can generate valid code with high confidence │
+├─────────────────────────────────────────────────────────────────────┤
+│ JOB 2: OVERRIDE/CREATE COMPONENTS (Swizzle Layer) │
+│ │
+│ npx xds swizzle Button │
+│ → src/components/xds/Button/Button.tsx │
+│ │
+│ Builder experience: │
+│ - Full component source, yours to modify │
+│ - Access to semantic CSS variables (--xds-color-primary) │
+│ - Documented customization points for AI assistance │
+├─────────────────────────────────────────────────────────────────────┤
+│ JOB 1: SET VISUAL STYLE (Theme Layer) │
+│ │
+│ const theme = createTheme({ │
+│ tokens: { color: { primary: '#0066cc' } }, │
+│ components: { button: { intents: {...} } } │
+│ }) │
+│ │
+│ Builder experience: │
+│ - Define tokens and component variants in one place │
+│ - Distributable as npm package │
+│ - Type-safe, validates against component requirements │
+└─────────────────────────────────────────────────────────────────────┘
+```
+
+### How the Jobs Relate
+
+| If the builder needs... | They use... | Complexity |
+|------------------------|-------------|------------|
+| Different colors | Theme tokens | Low |
+| New button variant | Theme component intents | Low |
+| Custom component structure | Swizzle | Medium |
+| New component behavior | New component | High |
+
+**Escalation path**: Theme → Swizzle → Custom. Each step up gives more control at the cost of more responsibility.
+
+---
+
+## Context
+
+Designing the architecture for XDS based on explorations in:
+- `frontend-developer-jtbd.md` — Developer jobs research, workflow phases
+- `zero-styling-architecture.md` — Components with no styles, theme-driven
+- `stylex-vs-tailwind.md` — StyleX core + `@xds/variants` wrapper, token tiers, AI considerations
+- `ai-trajectory-predictions.md` — Constraints beat suggestions
+- `ai-design-system-gaps.md` — Types as enforcement
+
+### Key Requirements
+
+1. **Zero-styling**: Components ship with no inline styles
+2. **AI-friendly**: Constrained, predictable, learnable patterns for all three jobs
+3. **Open source compatible**: Users define their own themes
+4. **Multi-design-system**: Different systems have different semantic lockups
+5. **Sub-part styling**: Style internal component slots (icons, labels, etc.)
+6. **Evolvable**: Base tokens stay internal, semantic tokens exposed for swizzle
+7. **Distributable**: Themes can be packaged and shared independently
+
+---
+
+## Core Architecture
+
+### Three-Layer System
+
+```
+┌─────────────────────────────────────────────────────────────────┐
+│ LAYER 3: COMPONENT API (Public) │
+│ │
+│ <Button intent="primary" size="md" /> │
+│ <ListItem intent="default" iconSlot={<Icon />} /> │
+│ │
+│ - Props define intent, not style │
+│ - Zero styling on components │
+│ - TypeScript enforces valid prop combinations │
+├─────────────────────────────────────────────────────────────────┤
+│ LAYER 2: THEME DEFINITION (User-Defined) │
+│ │
+│ const myTheme = createTheme({ │
+│ button: { │
+│ intents: { primary: {...}, secondary: {...} }, │
+│ sizes: { sm: {...}, md: {...}, lg: {...} }, │
+│ parts: { icon: {...}, label: {...} } │
+│ } │
+│ }) │
+│ │
+│ - Users define their design system's semantic lockup │
+│ - Maps intents → visual properties │
+│ - Includes sub-part styling │
+├─────────────────────────────────────────────────────────────────┤
+│ LAYER 1: DESIGN TOKENS (Internal + Swizzle) │
+│ │
+│ Semantic: --xds-color-primary, --xds-spacing-md │
+│ Base: (documentation only, not in code) │
+│ │
+│ - Semantic tokens available for swizzle │
+│ - Base colors never exposed in code │
+└─────────────────────────────────────────────────────────────────┘
+```
+
+---
+
+## Handling Different Semantic Lockups
+
+### The Problem
+
+Different design systems have different semantic structures:
+
+| Design System | Button Intents |
+|---------------|----------------|
+| System A | primary, secondary, tertiary |
+| System B | primary, secondary, danger, ghost, link |
+| System C | filled, outlined, text |
+| System D | brand, neutral, destructive, success |
+
+How does XDS support all of these with a single component library?
+
+### Solution: Intent Mapping Layer
+
+```typescript
+// XDS provides a "universal" set of slots
+type XDSButtonSlots = {
+ primary: ButtonStyles;
+ secondary: ButtonStyles;
+ tertiary: ButtonStyles;
+ danger: ButtonStyles;
+ ghost: ButtonStyles;
+ link: ButtonStyles;
+ // ... extensible
+};
+
+// User theme maps their semantic concepts to XDS slots
+const systemATheme = createTheme({
+ button: {
+ intents: {
+ primary: { /* styles */ },
+ secondary: { /* styles */ },
+ tertiary: { /* styles */ },
+ // danger, ghost, link → undefined (not used in System A)
+ }
+ }
+});
+
+// Component only shows valid intents for that theme
+<Button intent="primary" /> // ✅ Valid in System A
+<Button intent="danger" /> // ❌ TypeScript error if not in theme
+```
+
+### How This Works
+
+1. **XDS defines a superset of possible intents** (union type)
+2. **Theme defines which intents are valid** (maps a subset)
+3. **TypeScript narrows the type** based on active theme
+4. **Invalid intents are compile-time errors**
+
+```typescript
+// Type narrowing based on theme
+type ThemeConfig = typeof systemATheme;
+type ValidIntents = keyof ThemeConfig['button']['intents'];
+// ValidIntents = 'primary' | 'secondary' | 'tertiary'
+
+// Button component uses narrowed type
+function Button<T extends ThemeConfig>({
+ intent
+}: {
+ intent: keyof T['button']['intents']
+}) { ... }
+```
+
+### Extensibility for Custom Intents
+
+Users can add intents not in XDS's superset:
+
+```typescript
+const customTheme = createTheme({
+ button: {
+ intents: {
+ primary: { /* ... */ },
+ secondary: { /* ... */ },
+ // Custom intent not in XDS superset
+ 'ai-suggested': { /* ... */ },
+ }
+ }
+});
+
+// Works because theme defines what's valid
+<Button intent="ai-suggested" /> // ✅ Valid
+```
+
+---
+
+## Sub-Part Styling (Slots)
+
+### The Problem
+
+Components have internal parts that need independent styling:
+- Button: icon, label, loading indicator
+- ListItem: leading icon, content, trailing action
+- Input: prefix, input, suffix, error message
+
+### Solution: Slot-Based Theme Structure
+
+```typescript
+const theme = createTheme({
+ button: {
+ intents: {
+ primary: {
+ // Base styles for the component
+ background: '--xds-color-primary',
+ color: '--xds-color-on-primary',
+
+ // Slot-specific styles
+ parts: {
+ icon: {
+ size: '--xds-icon-md',
+ color: 'inherit',
+ },
+ label: {
+ font: '--xds-font-button',
+ weight: '--xds-font-weight-medium',
+ },
+ loadingIndicator: {
+ color: 'currentColor',
+ }
+ }
+ }
+ }
+ },
+
+ listItem: {
+ intents: {
+ default: {
+ padding: '--xds-spacing-md',
+
+ parts: {
+ leadingIcon: {
+ size: '--xds-icon-sm',
+ color: '--xds-color-secondary',
+ },
+ content: {
+ font: '--xds-font-body',
+ },
+ trailingAction: {
+ // inherits from parent by default
+ }
+ }
+ }
+ }
+ }
+});
+```
+
+### How Components Consume Slots
+
+```typescript
+// Component definition with typed slots
+interface ButtonParts {
+ icon?: ReactNode;
+ label: ReactNode;
+ loadingIndicator?: ReactNode;
+}
+
+function Button({
+ intent,
+ children,
+ icon,
+ isLoading
+}: ButtonProps) {
+ const theme = useTheme();
+ const styles = theme.button.intents[intent];
+
+ return (
+ <button {...stylex.props(styles.base)}>
+ {icon && (
+ <span {...stylex.props(styles.parts.icon)}>
+ {icon}
+ </span>
+ )}
+ <span {...stylex.props(styles.parts.label)}>
+ {children}
+ </span>
+ {isLoading && (
+ <Spinner {...stylex.props(styles.parts.loadingIndicator)} />
+ )}
+ </button>
+ );
+}
+```
+
+### Slot Inheritance
+
+Slots can inherit from parent or override:
+
+```typescript
+parts: {
+ icon: {
+ color: 'inherit', // Inherits from button color
+ },
+ label: {
+ color: '--xds-color-on-primary', // Explicit override
+ }
+}
+```
+
+---
+
+## Theme Definition API
+
+### Light/Dark Mode Enforcement
+
+All color tokens are **required** to be `[light, dark]` pairs — TypeScript enforces this:
+
+```typescript
+type LightDarkPair = [light: string, dark: string];
+
+// ❌ Type error: expected [string, string]
+primary: '#0066cc',
+
+// ✅ Valid: both light and dark values
+primary: ['#0066cc', '#66b3ff'],
+```
+
+### The "on*" Pattern
+
+Every background color has a corresponding foreground color for accessible contrast:
+
+```
+primary → onPrimary (text color when on primary background)
+surface → onSurface (general text color)
+danger → onDanger (text on danger background)
+```
+
+### createTheme Function
+
+```typescript
+import { createTheme } from '@xds/core';
+
+export const myTheme = createTheme({
+ tokens: {
+ color: {
+ // Surfaces — [light, dark]
+ background: ['#ffffff', '#121212'],
+ onBackground: ['#1a1a1a', '#e0e0e0'],
+ surface: ['#f5f5f5', '#1e1e1e'],
+ onSurface: ['#1a1a1a', '#e0e0e0'],
+
+ // Brand — [light, dark]
+ primary: ['#0066cc', '#66b3ff'],
+ onPrimary: ['#ffffff', '#000000'],
+ secondary: ['#6b7280', '#9ca3af'],
+ onSecondary: ['#ffffff', '#000000'],
+
+ // Semantic — [light, dark]
+ danger: ['#dc2626', '#f87171'],
+ onDanger: ['#ffffff', '#000000'],
+ success: ['#16a34a', '#4ade80'],
+ onSuccess: ['#ffffff', '#000000'],
+
+ // Borders
+ border: ['#e5e7eb', '#374151'],
+ borderFocus: ['#0066cc', '#66b3ff'],
+ },
+
+ spacing: {
+ xs: '0.25rem',
+ sm: '0.5rem',
+ md: '1rem',
+ lg: '1.5rem',
+ xl: '2rem',
+ },
+
+ radius: {
+ sm: '0.25rem',
+ md: '0.5rem',
+ lg: '1rem',
+ full: '9999px',
+ },
+
+ typography: {
+ fontFamily: {
+ sans: 'Inter, system-ui, sans-serif',
+ mono: 'JetBrains Mono, monospace',
+ },
+ fontSize: {
+ sm: '0.875rem',
+ md: '1rem',
+ lg: '1.125rem',
+ }
+ },
+ },
+
+ // Component-specific theming
+ components: {
+ button: {
+ intents: { /* ... */ },
+ sizes: { /* ... */ },
+ parts: { /* ... */ },
+ },
+ input: { /* ... */ },
+ listItem: { /* ... */ },
+ }
+});
+
+type MyTheme = typeof myTheme;
+```
+
+### Generated CSS Output
+
+Themes generate CSS using the `light-dark()` function:
+
+```css
+:root {
+ color-scheme: light dark;
+
+ /* Colors with automatic light/dark support */
+ --xds-color-primary: light-dark(#0066cc, #66b3ff);
+ --xds-color-on-primary: light-dark(#ffffff, #000000);
+ --xds-color-background: light-dark(#ffffff, #121212);
+ --xds-color-on-background: light-dark(#1a1a1a, #e0e0e0);
+
+ /* Spacing (no light/dark needed) */
+ --xds-spacing-sm: 0.5rem;
+ --xds-spacing-md: 1rem;
+}
+```
+
+Components reference these variables and automatically adapt to light/dark mode.
+
+### Manual Mode Override
+
+For apps that want manual light/dark toggle:
+
+```tsx
+// Follow system preference (default)
+<XDSProvider theme={myTheme} mode="system">
+
+// Force dark mode
+<XDSProvider theme={myTheme} mode="dark">
+
+// Force light mode
+<XDSProvider theme={myTheme} mode="light">
+```
+
+### Using the Theme
+
+```typescript
+import { XDSProvider } from '@xds/core';
+import { myTheme } from './theme';
+
+function App() {
+ return (
+ <XDSProvider theme={myTheme}>
+ <Button intent="primary" size="md">
+ Click me
+ </Button>
+ </XDSProvider>
+ );
+}
+```
+
+### Theme Composition
+
+Themes can extend other themes:
+
+```typescript
+import { baseTheme } from '@xds/themes/base';
+
+const myTheme = createTheme({
+ extends: baseTheme,
+
+ // Override specific parts
+ tokens: {
+ color: {
+ primary: '#custom-brand-color',
+ }
+ },
+
+ components: {
+ button: {
+ intents: {
+ // Add a new intent
+ 'custom-cta': { /* ... */ }
+ }
+ }
+ }
+});
+```
+
+---
+
+## AI Compatibility Considerations
+
+### AI-Friendliness by Job
+
+| Job | AI Difficulty | Why |
+|-----|---------------|-----|
+| **Construct pages** | ✅ Easy | Typed props, autocomplete, finite options |
+| **Set visual style** | ⚠️ Medium | Theme structure is learnable, but separate from components |
+| **Override components** | ⚠️ Medium | Documented patterns, semantic tokens, but unfamiliar StyleX |
+
+### Why This Architecture Is AI-Friendly
+
+| Design Decision | AI Benefit |
+|-----------------|------------|
+| **Props, not classes** | `intent="primary"` is learnable; `bg-blue-500 hover:bg-blue-600` is arbitrary |
+| **TypeScript enforcement** | Invalid props fail at compile time, AI gets immediate feedback |
+| **Finite intent set** | AI learns discrete options, not infinite styling possibilities |
+| **Consistent patterns** | Same API shape across all components |
+| **No arbitrary values** | Can't generate `mt-[13px]`, only valid tokens |
+| **Re-export pattern** | Concrete types in one file, no cross-package reasoning |
+
+### The Author vs Consumer Gap
+
+The "AI gap" is primarily for **component authors**, not **component consumers**.
+
+| Role | API Surface | AI Difficulty |
+|------|-------------|---------------|
+| **Consumer** (Job 3) | `<Button intent="primary" size="md">` | Trivial — typed props, autocomplete |
+| **Theme author** (Job 1) | `createTheme({ ... })` | Medium — structured, learnable |
+| **Swizzler** (Job 2) | StyleX + semantic CSS variables | Medium — documented patterns |
+| **Component author** | `createVariants({ ... stylex.create() ... })` | Higher — unfamiliar patterns |
+
+**Why this matters**: Most users are consumers (Job 3). They never touch StyleX — they just use typed props.
+
+### Theme as AI Context
+
+Themes are structured data that can be included in AI context:
+
+```typescript
+// Theme can be serialized for LLM context
+const themeContext = {
+ availableIntents: {
+ button: ['primary', 'secondary', 'danger'],
+ input: ['default', 'error', 'success'],
+ },
+ availableSizes: ['sm', 'md', 'lg'],
+ // ...
+};
+```
+
+This enables AI to:
+1. Know valid prop values without reading source
+2. Generate only theme-valid code
+3. Adapt to different themes dynamically
+
+---
+
+## Tailwind Interoperability
+
+### Exporting Theme as CSS Variables
+
+```typescript
+// Auto-generated from theme
+:root {
+ --xds-color-primary: #0066cc;
+ --xds-color-secondary: #6b7280;
+ --xds-spacing-md: 1rem;
+ /* ... */
+}
+```
+
+### Tailwind Preset
+
+```css
+/* @xds/tailwind-preset */
+@import "tailwindcss";
+@import "@xds/tokens/css";
+
+@theme {
+ --color-primary: var(--xds-color-primary);
+ --color-secondary: var(--xds-color-secondary);
+ --spacing-md: var(--xds-spacing-md);
+ /* ... */
+}
+```
+
+Now Tailwind users can use XDS tokens:
+
+```html
+<div class="bg-primary text-on-primary p-md">
+ Tailwind with XDS tokens
+</div>
+```
+
+### Linting for Arbitrary Values
+
+Provide ESLint/Stylelint rules to prevent:
+
+```html
+<!-- ❌ Flagged by lint -->
+<div class="bg-[#0066cc] mt-[13px]">
+
+<!-- ✅ Allowed -->
+<div class="bg-primary mt-md">
+```
+
+---
+
+## Swizzle API
+
+**Job 2: Override/Create Components** — When theme customization isn't enough.
+
+Based on exploration in `swizzle-layer-ergonomics.md`, the swizzle layer serves two distinct personas with different needs.
+
+### Two Personas
+
+| Persona | Goal | Skill Level | Swizzle Use |
+|---------|------|-------------|-------------|
+| **DS Team** | Customize appearance to match brand | High — willing to learn StyleX | Heavy, styling-focused |
+| **Regular Builder** | Unblock a specific functionality | Medium — wants to ship fast | Minimal, functionality-focused |
+
+### Dual-Path Swizzle
+
+```
+┌─────────────────────────────────────────────────────────────────┐
+│ PATH A: STYLING CUSTOMIZATION (customize) │
+│ │
+│ npx xds customize Button --theme=myTheme │
+│ → Generates theme extension (AI-friendly config) │
+│ │
+│ For: DS teams, adding intents, tweaking tokens │
+│ AI vibes: ✅ Excellent — structured data │
+├─────────────────────────────────────────────────────────────────┤
+│ PATH B: FUNCTIONAL OVERRIDE (swizzle) │
+│ │
+│ npx xds swizzle Button │
+│ → Full source with AI-friendly annotations │
+│ │
+│ For: Builders needing behavior changes │
+│ AI vibes: ⚠️ Medium — unfamiliar but documented │
+└─────────────────────────────────────────────────────────────────┘
+```
+
+### Path A: Theme Extension (Styling)
+
+For DS teams that want to customize appearance without changing structure.
+
+```bash
+npx xds customize Button --theme=corporate
+```
+
+**Generated file** (`themes/corporate/button.ts`):
+```typescript
+// AI-friendly format: structured config, not code
+import { extendTheme } from '@xds/core';
+
+export const corporateButtonTheme = extendTheme({
+ component: 'button',
+
+ intents: {
+ 'brand-primary': {
+ background: '--corporate-blue',
+ color: 'white',
+ },
+ },
+
+ sizes: {
+ lg: { padding: '16px 32px', fontSize: '18px' },
+ },
+});
+```
+
+**Why AI-friendly**: Structured config format, clear property names, predictable schema.
+
+### Path B: Full Swizzle (Functionality)
+
+For builders who need to change behavior or structure.
+
+```bash
+npx xds swizzle Button
+```
+
+**Generated file** — Full source with heavy documentation:
+```typescript
+/**
+ * 🎨 SWIZZLED COMPONENT: Button
+ *
+ * COMMON CUSTOMIZATIONS:
+ * 1. Add custom behavior: see line 45
+ * 2. Modify structure: see line 89
+ * 3. Styling changes: use semantic tokens (var(--xds-color-primary))
+ */
+
+const button = createVariants({
+ // 👇 CUSTOMIZE: Base styles
+ base: stylex.create({ root: { cursor: 'pointer' } }).root,
+
+ // 👇 CUSTOMIZE: Add or modify intents
+ variants: { /* ... */ },
+});
+
+export function Button({ intent, onClick, children }) {
+ // 👇 CUSTOMIZE: Add custom behavior (tracking, analytics)
+ const handleClick = () => { onClick?.(); };
+
+ return <button onClick={handleClick}>{children}</button>;
+}
+```
+
+**Why this works despite StyleX**:
+- Extensive inline documentation (AI reads comments)
+- Clear customization markers (👇 CUSTOMIZE)
+- Examples in comments
+- Semantic tokens only (no raw StyleX internals)
+
+### When to Use Which Path
+
+| Builder needs... | Recommended path |
+|-----------------|------------------|
+| Different colors/spacing | **Path A** (customize) |
+| New button intent | **Path A** (customize) |
+| Custom click tracking | **Path B** (swizzle) |
+| Different validation logic | **Path B** (swizzle) |
+| Custom keyboard behavior | **Path B** (swizzle) |
+| Structural changes | **Path B** (swizzle) |
+
+### Swizzle Versioning
+
+Swizzled components are "ejected" — they don't auto-update:
+
+```
+⚠️ Swizzled component: Button
+ Source version: @xds/[email protected]
+ Last synced: 2026-01-15
+
+ This component is now your responsibility.
+ Check @xds/core changelog for updates.
+```
+
+### Format Options
+
+For builders who prefer Tailwind patterns:
+
+```bash
+# Default (StyleX) — maximum encapsulation
+npx xds swizzle Button
+
+# Tailwind format — familiar syntax, better AI vibes
+npx xds swizzle Button --format=tailwind
+```
+
+| Format | Best for | Tradeoff |
+|--------|----------|----------|
+| `stylex` (default) | DS teams, maximum control | Less familiar, learning curve |
+| `tailwind` | Regular builders, fast shipping | Classes in DOM, less encapsulation |
+
+Both formats use XDS tokens — no arbitrary values allowed. See `swizzle-layer-ergonomics.md` for detailed examples.
+
+---
+
+## Distributable Themes
+
+**Job 1: Set Visual Style** — Themes can be packaged and shared independently.
+
+### Theme as npm Package
+
+```
+@company/dark-theme/
+├── package.json
+├── theme.ts # Theme definition
+├── index.ts # Exports theme + types
+└── tokens.css # Generated CSS variables
+```
+
+```typescript
+// @company/dark-theme/theme.ts
+import { createTheme } from '@xds/core';
+
+export const darkTheme = createTheme({
+ tokens: {
+ color: {
+ primary: '#6366f1',
+ background: '#1a1a2e',
+ // ...
+ }
+ },
+ components: {
+ button: {
+ intents: {
+ primary: { /* ... */ },
+ secondary: { /* ... */ },
+ }
+ }
+ }
+});
+
+export type DarkTheme = typeof darkTheme;
+```
+
+### Type-Safe Theme Consumption
+
+When themes are separate packages, components need to know what intents are available.
+
+**Recommended pattern: Re-export with concrete types**
+
+```typescript
+// src/components/index.ts — App-level typed components
+import { Button as XDSButton, Input as XDSInput } from '@xds/core';
+import { darkTheme, DarkTheme } from '@company/dark-theme';
+
+// Re-export with concrete types
+export const Button = XDSButton<DarkTheme>;
+export const Input = XDSInput<DarkTheme>;
+
+// Now intent is concretely typed: 'primary' | 'secondary'
+// AI sees simple, concrete types — no generics to reason about
+```
+
+**App setup**:
+```typescript
+// src/App.tsx
+import { XDSProvider } from '@xds/core';
+import { darkTheme } from '@company/dark-theme';
+import { Button } from './components';
+
+function App() {
+ return (
+ <XDSProvider theme={darkTheme}>
+ <Button intent="primary">Click me</Button>
+ </XDSProvider>
+ );
+}
+```
+
+### Theme Distribution Tradeoffs
+
+| Approach | Type Safety | AI Context Required | Recommendation |
+|----------|-------------|---------------------|----------------|
+| **Generic components** | ✅ Full | Theme type in scope | Power users |
+| **Re-export with concrete types** | ✅ Full | Just component file | **Default pattern** |
+| **Superset intents** | ⚠️ Runtime | Just component | Simpler but less safe |
+
+The re-export pattern gives AI a single file with concrete types — no cross-package reasoning required.
+
+---
+
+## Open Questions
+
+### Resolved
+
+1. ~~**Light/dark mode support?**~~ → **Resolved**: Color tokens are always `[light, dark]` pairs. CSS uses `light-dark()` function. TypeScript enforces pairs.
+
+2. ~~**Swizzle layer ergonomics?**~~ → **Resolved**: Dual-path approach (Path A: customize for styling, Path B: swizzle for functionality). See `swizzle-layer-ergonomics.md`.
+
+### Unresolved Design Decisions
+
+1. **How deep should slot nesting go?**
+ - `button.parts.icon.hover` or just `button.parts.icon`?
+ - Risk of over-specification vs. flexibility
+
+2. **Should themes be runtime or compile-time?**
+ - Compile-time: Better performance, type safety
+ - Runtime: Dynamic theming, user preferences
+ - Hybrid: Base at compile-time, overrides at runtime?
+
+3. **How to handle responsive tokens?**
+ - `spacing: { md: { default: '1rem', '@md': '1.5rem' } }`
+ - Or separate responsive layer?
+
+4. **Theme validation/linting?**
+ - Warn if theme is missing required intents?
+ - Provide a `validateTheme()` function?
+
+5. **Default theme?**
+ - Should XDS ship a default theme?
+ - Or require users to always define one?
+
+### Distributable Themes
+
+7. **Generic components vs re-export pattern?**
+ - Should we enforce the re-export pattern?
+ - Or make generic components ergonomic enough for direct use?
+
+8. **Theme CLI tooling?**
+ - `npx xds init-theme` to scaffold a theme package?
+ - `npx xds generate-components` to create typed re-exports?
+
+9. **Runtime theme switching with type safety?**
+ - How do we switch themes while maintaining compile-time type checks?
+ - Union of all possible theme intents?
+
+### `@xds/variants` Implementation
+
+10. **Type inference complexity?**
+ - How do we infer variant props from nested StyleX objects?
+ - Should variants reference theme tokens or be self-contained?
+
+11. **Responsive variants?**
+ - Should responsive breakpoints be part of variant API?
+ - Or handled via StyleX media queries?
+
+---
+
+## Styling Technology
+
+### Decision: StyleX + `@xds/variants` Wrapper
+
+Based on exploration in `stylex-vs-tailwind.md`, the recommended approach is:
+
+**StyleX** for the styling engine:
+- Compile-time CSS extraction, zero runtime
+- Full TypeScript integration
+- Scoped theming is first-class
+- No exposed CSS classes to consumers
+
+**`@xds/variants`** wrapper for ergonomics:
+- tw-classed-like variant API
+- Slots for sub-part styling
+- Compound variants, default variants
+- Type inference from variant definition
+
+**Tailwind preset** for ecosystem compatibility:
+- XDS tokens available as Tailwind utilities
+- Interop without compromising enforcement
+
+### Why Not Pure Tailwind?
+
+| Issue | Impact |
+|-------|--------|
+| Arbitrary values bypass constraints | AI can generate `mt-[13px]` |
+| Classes are public | Consumers can depend on implementation details |
+| Theme tokens are all public CSS vars | Can't evolve without breaking consumers |
+| Type safety is weak | No compile-time enforcement |
+
+### Component Authoring with `@xds/variants`
+
+```typescript
+import { createVariants } from '@xds/variants';
+import * as stylex from '@stylexjs/stylex';
+
+const button = createVariants({
+ base: stylex.create({
+ root: { cursor: 'pointer', borderRadius: 4 }
+ }).root,
+
+ slots: {
+ icon: stylex.create({ root: { width: 16, height: 16 } }).root,
+ label: stylex.create({ root: { fontWeight: 500 } }).root,
+ },
+
+ variants: {
+ intent: {
+ primary: stylex.create({
+ root: { backgroundColor: 'var(--xds-color-primary)' }
+ }).root,
+ secondary: stylex.create({
+ root: { backgroundColor: 'var(--xds-color-secondary)' }
+ }).root,
+ },
+ size: {
+ sm: stylex.create({ root: { padding: 4, fontSize: 14 } }).root,
+ md: stylex.create({ root: { padding: 8, fontSize: 16 } }).root,
+ }
+ },
+
+ defaultVariants: {
+ intent: 'primary',
+ size: 'md',
+ }
+});
+
+// TypeScript infers: { intent: 'primary' | 'secondary', size: 'sm' | 'md' }
+```
+
+This provides tw-classed ergonomics without exposed CSS classes.
+
+---
+
+## Proposed Implementation Phases
+
+### Phase 1: Core Infrastructure
+- `@xds/variants` wrapper around StyleX — tw-classed-like ergonomics with compile-time enforcement
+- `createTheme()` function with TypeScript inference
+- `XDSProvider` context
+- Basic token system (colors, spacing, typography)
+- 3-5 pilot components (Button, Input, Text, Box, Stack)
+
+### Phase 2: Component Library
+- Full component set with intent/size/part slots
+- Swizzle CLI
+- Storybook integration
+
+### Phase 3: Ecosystem
+- Tailwind preset
+- CSS variable export
+- Lint rules for arbitrary value prevention
+- Theme gallery / community themes
+
+### Phase 4: Advanced Features
+- Runtime theme switching
+- Responsive tokens
+- Animation tokens
+- Multi-theme composition
+
+---
+
+## Related Explorations
+
+- `frontend-developer-jtbd.md` — Developer jobs research, workflow phases
+- `swizzle-layer-ergonomics.md` — Dual-path swizzle approach, AI-friendliness
+- `zero-styling-architecture.md` — Foundational concept
+- `stylex-vs-tailwind.md` — Styling technology choice, token tiers, `@xds/variants` wrapper approach
+- `ai-trajectory-predictions.md` — Why constraints matter long-term
+- `required-props-pattern.md` — Explicit APIs for AI
+- `distribution-methods.md` — How themes will be distributed
+
+---
+
+## Sources
+
+- [Rangle.io: Token Structure](https://Rangle.io/blog/developing-your-token-structure)
+- [StyleX Theming Guide](https://stylexjs.com/docs/learn/theming/creating-themes/)
+- [Tailwind v4 Theme Docs](https://tailwindcss.com/docs/theme)
+- [UXPin: Component-Based Design](https://www.uxpin.com/studio/blog/component-based-design-complete-implementation-guide/)