Repository navigation
Description
Context
We built an interactive theme builder as a consuming project to test the XDS source distribution workflow end-to-end. The goal was to understand what it's like to build a real app with XDS — from installation to creating proper StyleX themes.
Initial prompt
Build a theme builder with a lightweight UI that lets me pick colors for each public CSS color token, set radius values, and use a single unit input that scales all spacing/sizes. Show a good set of demo components in the middle (card with layout, table, buttons, inputs — like a todo list). All controls should use XDS components. Support saving themes to localStorage, switching between them, and exporting valid XDS theme files. Start with neutral wireframe defaults. Changes should not apply immediately — use an Apply button with a brush sweep animation.
Sample themes created
Default, Wireframe, Meta AI (inspired by Meta AI branding), Midnight (dark), Warm Earth (organic tones), Brutalist (zero radius, black borders, hot pink accent).
What went well
-
Source distribution packaging works.
yarn package:source→npm pack→npm install ./tarballinstalled@xds/coreintonode_moduleswith raw source. Components imported and compiled cleanly. -
StyleX compilation at the app level works. Both the PostCSS path (Next.js) and the babel plugin correctly compiled XDS component styles alongside app styles. The 42KB extracted CSS included all tokens, atomic classes, and theme variants.
-
Component API is solid. Building the todo list demo (XDSButton, XDSTextInput, XDSCheckboxInput, XDSCard, XDSVStack/XDSHStack, XDSBadge, XDSDivider, XDSHeading/XDSText, XDSLayout) felt natural. The components composed well together.
-
XDSLayout is good. Header/Panel/Content slots with
hasDivider,isScrollable, andwidthprops made the sidebar layout clean. -
Theme switching with XDSTheme provider works. Once the themes were proper
createThemeobjects, switching between them via the provider was instant and correct. -
Creating proper StyleX themes is doable. The pattern of
createTheme(colorVars, colorRaw)for each token group, assembled into aThemeobject, works well once you know the shape.
Hiccups and gaps
1. Import resolution for createTheme across packages is the hardest part
This was the single biggest friction point. createTheme() requires StyleX to statically resolve the original defineVars() call. When theme files in the consuming project import tokens via @xds/core/theme/tokens.stylex, the StyleX babel plugin needs aliases configured to find the source:
aliases: {
'@xds/core/*': [path.join(rootDir, 'node_modules/@xds/core/*')],
'@xds/core': [path.join(rootDir, 'node_modules/@xds/core')],
}Without this, you get a cryptic nonStaticValue error from the babel plugin. This needs to be prominently documented — it's not obvious and the error message doesn't suggest the fix. Even knowing it was an aliases issue, getting the exact config right took multiple attempts.
Recommendation: The package-source.js script or CLI init command should generate a starter babel.config.js with the correct aliases pre-configured.
2. PostCSS setup has silent failure modes
- The
@stylex;at-rule in the CSS file is required for the PostCSS plugin to extract styles. Without it, PostCSS produces an empty CSS file with no error or warning. This cost debugging time. - The
includepattern must explicitly covernode_modules/@xds/core/**— PostCSS only scans app source by default.
Recommendation: Add validation or warnings when the PostCSS plugin finds no StyleX rules to extract.
3. 'use client' boundary needed for XDSTheme
XDS components use createContext but don't include 'use client' directives. In Next.js App Router, the theme provider needs to be wrapped in a client component. This is a known pattern but should be documented in the setup guide.
4. Color editing UX needs work
- Too many individual color pickers. 50+ color tokens is overwhelming. Setting them one by one is tedious and it's hard to create a cohesive palette.
- No light/dark mode support. XDS tokens use
light-dark()but the builder only sets single values. Setting both light and dark values would double the already-large number of inputs. - Recommendation: A "derive from palette" approach where you pick 3-5 key colors (accent, surface, text, positive, negative) and the builder derives the full token set (deemphasized variants, icon colors, divider colors, etc.) would be much more practical.
5. Default appearance is too gray/flat
The wireframe starting point renders everything in neutral grays, which makes the initial experience feel broken rather than intentionally minimal. Primary buttons appear as gray solid fills rather than outlined/ghost — losing the wireframe aesthetic.
Recommendation: Wireframe defaults should use outlined/ghost styling for primary actions, and the overall feel should look more like a deliberate wireframe than a broken theme.
6. LightningCSS polyfills light-dark()
Vite's LightningCSS transformer lowers light-dark() into --lightningcss-light/--lightningcss-dark custom properties when targeting older browsers. This creates unexpected CSS output. Fixed by setting explicit CSS targets in the Vite config (Chrome 123+, Firefox 120+, Safari 17.5+).
7. Input components need CSS resets
Input containers were missing box-sizing: border-box, causing overflow when padding was applied. Inner <input> elements in some components showed browser default borders. (Fixed in PR #152.)
8. The brush sweep animation added complexity
The reveal animation was a fun idea but made the apply flow harder to debug. The boolean trigger pattern caused stale closure issues (fixed by switching to a counter). The animation itself is subtle enough that it's easy to miss — unclear if it's worth the complexity.
9. Theme builder still has issues
The theme builder is not fully working yet — there are remaining bugs with theme application and the overall flow needs more polish before it's usable as a standalone tool.
Where human intervention was necessary
-
Identifying the PostCSS requirement. The initial setup used
@stylexjs/nextjs-plugin(webpack path) which worked but the StyleX team recommends the PostCSS path for Next.js. Human pointed to the StyleX example-nextjs as the reference. -
Aliases config for cross-package createTheme. The LLM tried relative paths, different import patterns, and various workarounds before the human confirmed "use aliases config" — which is what the StyleX team had suggested.
-
Architecture decisions. Human directed: use proper StyleX themes (not CSS var objects), use XDSTheme provider (not manual style injection), remove the card border gradient hack (it should be part of the theme, not a separate control).
-
Debugging theme application. The LLM's initial brush sweep implementation had stale closure bugs. The human had to report that "apply isn't working" and "background always appears white" — the LLM couldn't test the runtime behavior.
-
Repo access. The XDS repo name (
facebookexperimental/xds) took a few tries to get right.
Missing features / future work
-
"Derive from palette" color input — Pick 3-5 key colors, auto-derive the full 50+ token set. This is the biggest UX improvement needed.
-
Light + dark mode editing — Currently only sets single values. Need a way to set both halves of
light-dark(). -
Live preview without Apply — Optional instant preview mode (in addition to the deliberate Apply flow) would speed up iteration.
-
Component style overrides — The theme builder only handles token values. XDS themes can also override component-specific styles (button variants, heading styles, etc.). The builder should support this.
-
Integration with XDS docs site — This should eventually live on the XDS documentation site as an interactive theme creation tool.
-
Better error messages for StyleX config issues — The silent failures and cryptic errors around
createThemeresolution need better DX. -
Starter config generation — The CLI
initcommand orpackage-source.jsshould generate correct babel/postcss configs with aliases pre-configured for the consumer's bundler.
Related
- Theme builder prototype: https://github.com/cixzhang/xds_sandbox/tree/theme-builder
- Source distribution setup issue: Add example-nextjs project for source distribution consumers #145
- Input styling fix: fix(inputs): reset input styling — border-box and border: none #151
- Theme package PR: feat(theme): separate themes into @xds/theme package #141
Activity
cixzhang commentedon Feb 19, 2026
Addendum: LLM component discovery gaps
XDSLayout wasn't reached for initially
The theme builder's page layout was initially built with manual flexbox (a raw
divwithdisplay: flex, hardcoded sidebar width, manual overflow/padding). The human had to explicitly ask "can you use an XDSLayout?" — at which point it was an obvious fit (XDSLayoutwithXDSLayoutHeader,XDSLayoutPanel,XDSLayoutContentslots).Why it was missed: The LLM treated the page shell as scaffolding around XDS components rather than something that should be built with XDS components.
XDSLayoutwas mentally categorized as a "content layout" tool rather than an "app shell" tool, even though the header/panel/content slot pattern is exactly an app shell.This is a component discovery problem. The LLM had access to the component source and could see the exports, but didn't connect "I need a sidebar layout" → "XDSLayout has a
startpanel slot." Better component documentation, usage examples, or naming could help here.CLI + agent docs flow was not tested
Notably, we did not use the
xds initorxds agent-docsCLI flow in this round. The LLM was working from raw source code and grep — no AGENTS.md guidance, no component documentation installed, no structured API reference.This is worth comparing in a future session where we:
xds initto set up the projectxds agent-docsto install the AGENTS.md with component guidanceThe hypothesis is that the agent docs — which include component descriptions, prop tables, and usage patterns — would have surfaced XDSLayout as the right tool for the job without human intervention. This session serves as the baseline without agent docs for that comparison.
cixzhang commentedon Feb 19, 2026
Wash background didn't apply
The theme builder's page background was supposed to use
--color-washbut stayed white regardless of the theme. This went through several failed attempts:backgroundColor: 'var(--color-wash)'in an inlinestylealongside the CSS custom property definitions — the var reference didn't resolve because React inline styles don't guarantee CSS custom property resolution order on the same element.Reading the value directly (
appliedVars['--color-wash']) — worked for the CSS var override path but not when usingXDSThemeprovider (where the wash color is set via StyleX classes, not inline vars).The root issue: XDSTheme uses
display: contentsand doesn't create a visual box, so it can't carry a background color. The theme sets--color-washas a CSS variable but nothing in the XDS system actually applies it as a background. Consumers are expected to set their ownbackground-color: var(--color-wash)somewhere — but this isn't documented and isn't obvious.This is a gap in the theme system. A common expectation is that wrapping your app in
<XDSTheme>gives you a fully themed page, including the background. Options:XDSThemecould optionally render a wrapper div withbackgroundColor: var(--color-wash)(opt-in via prop)XDSLayoutcould apply wash as its background by defaultThis tripped up both the LLM and the human — it's a real DX gap, not just an LLM discovery problem.
cixzhang commentedon Feb 19, 2026
Component style overrides are hard for LLMs to discover
The XDS theme system supports component-level style overrides via module augmentation:
Then in a theme:
Why this is hard for LLMs:
The pattern is unusual. Module augmentation to extend an interface across files isn't a common React pattern. LLMs default to wrapper components, CSS var hacks, or inline styles instead.
Discovery requires cross-file reading. You need to find the
declare modulein the component source, understand the augmentation target, then look at how existing themes use it. There's no single place that says "here's how to style cards in a theme."The
as Theme['components']assertion is a red flag. It signals that the type system can't fully verify this, which makes LLMs less confident about using it.What happened: When asked for rainbow gradient borders on Meta AI cards, the LLM created a
ThemedCardwrapper component that manually applied CSS vars for gradient borders — completely bypassing the theme system. The human had to explicitly say "we shouldn't need to do that" and point back to proper theme component overrides.What could help:
xds theme scaffoldCLI command that generates a theme file template with all component override slots commented outComponentStylesaugmentation is invisible unless you know to look fordeclare modulecixzhang commentedon Feb 19, 2026
On discoverability: retrieval over directives
The XDSLayout source was in the LLM's context window — it had read the component files and seen the slot-based API, padding management, and scroll containment. But it didn't connect "my layout has weird spacing" → "XDSLayout exists for this."
What wouldn't help: Adding "always use XDSLayout for page layouts" to the docs. This creates a tragedy of the commons — if every component says "always use me," the urgency becomes noise and LLMs learn to ignore it.
What would help: Making the connection discoverable through retrieval-based reasoning:
Use-case-oriented descriptions — "XDSLayout — Page shell with header, sidebar, and content slots. Manages padding collapse, scroll containment, and responsive slot sizing." This lets the LLM match its problem ("I need a sidebar with proper padding") to the component.
Decision trees in agent docs — "Building a page with a sidebar? → XDSLayout. Stacking items vertically? → XDSVStack. Need a scrollable content area? → XDSLayoutContent." This is retrieval-friendly — the LLM searches for its problem and finds the answer.
Full-page examples — Component docs that show XDSLayout in a complete page context (not just the component in isolation). When the LLM thinks "I need a sidebar layout," retrieval pulls up the example.
This scales better than directive-based docs because the LLM looks up what it needs when it needs it, rather than trying to hold every rule in working memory.
cixzhang commentedon Feb 19, 2026
Comparison: XDS components vs raw HTML + StyleX
We built the same theme builder twice — once with XDS components, once with raw HTML + StyleX only — to compare the experience and output.
Bundle size
Tree-shaking works correctly — only imported components and their dependencies are bundled. The 58.6KB comes from:
Of that 58.6KB, ~26KB (44%) could be lazy-loaded — the tooltip/layer system (12.2KB), field system (8KB), spinner (2.7KB), and icon (3.1KB) are pulled in as dependencies even when their features aren't used. See #157 for the tooltip analysis.
Code volume
The raw version has to style every button, input, card, badge, table, and layout from scratch. The XDS version reuses all of that.
Setup complexity
The raw version built on the first try. The XDS version required debugging PostCSS config, aliases,
@stylex;directive, and'use client'boundaries.Development experience
Key takeaway
The raw version is faster to set up and produces a smaller bundle, but requires significantly more code and provides no accessibility, consistency, or theme system guarantees. The XDS version's setup friction is almost entirely from the source distribution model (PostCSS, aliases, transpilePackages) — not from the components themselves. If that setup were smoother (e.g., a CLI that generates the config), the XDS version would be strictly better.
Repos
cixzhang commentedon Feb 20, 2026
Feedback on theme-builder-raw
Tried out the raw version — it looks quite good, actually better than the first iteration with XDS.
The LLM did well covering the major, larger areas like layout but did worse on smaller details like input and button relative sizing.
This is an interesting signal for the comparison: the raw version gives the LLM more direct control over every detail, but it still struggles with the finer points of visual consistency (relative sizing between inputs and buttons, proportional spacing). These are exactly the things a design system is supposed to handle for you — which reinforces the value proposition of XDS even as the raw version "looks better" at a glance.
docs(layout): improve descriptions for LLM discoverability
cixzhang commentedon Feb 20, 2026
For posterity, here's a set of screenshots:
| Using XDS (initial state) |
|
|
|
| Using XDS (after XDSLayout refinement) |
| Raw HTML + stylex |
cixzhang commentedon Feb 20, 2026
We will attempt again after our refinements have landed tonight.
docs(layout): improve descriptions for LLM discoverability (#198)
cixzhang commentedon Feb 20, 2026
Here's a screenshot of the second attempt after day 1 fixes.
It's much improved. There are still some hiccups related to the LLM's understanding of our layouts and built-in paddings/scrollable areas to work through.
cixzhang commentedon Feb 20, 2026
Theme Builder v2 — experience report
Re-attempted the theme builder exercise after landing doc improvements from today's session. Built on
cixzhang/xds_sandbox@theme-builder-v2.What improved
XDSLayout was reached for immediately. The LLM used
XDSLayoutfor the page shell without prompting — the updated@positiontags and "When to use" decision tree worked. No manual flexbox for the page structure.XDSTopNav went directly in the header slot. The new docs showing TopNav composing without an XDSLayoutHeader wrapper were picked up correctly. No
isFullBleedorhasDivider={false}overrides needed."Derive from palette" approach was used. The LLM built 8 key color inputs that derive the full ~80 token set, rather than showing all 80 individually. This was one of the v1 recommendations.
Overall layout quality is much better compared to the first iteration with XDS. The page shell structure (header + sidebar + content) was correct from the start.
What still tripped up
Double padding and scrollbars. The LLM added
paddingInline,paddingBlock, andoverflowY: 'auto'to components insideXDSLayoutPanelandXDSLayoutContent, not realizing these slots already provide their own padding and scroll containment. This caused doubled spacing and nested scrollbars.20 missing subpath exports in the tarball. The LLM correctly used subpath imports like
@xds/core/TopNav,@xds/core/Slider, etc. — but they weren't in the package.json exports map. Thepackage-source.jsscript only mapped exports already inpackages/core/package.json, missing components like TopNav, TabList, Slider, Switch, NumberInput, RadioList, Table, StatusDot, and 12 others.index.ts.Input/button relative sizing still weak. Same observation as the raw version — the LLM does well on layout structure but struggles with finer details like relative sizing between inputs and buttons. The button showcase in the side panel shows all sizes but they don't feel cohesive with the input sizing next to them.
Stale localStorage crash. The hook loaded saved themes from localStorage without validating the data shape, causing a crash when old data from a previous session didn't match the expected
SavedThemeEntryformat.Sub-agent coordination gaps. The page.tsx referenced
sweepCountfrom the hook, but the hook sub-agent didn't include it. Thesave()function signature ((name?: string) => void) was incompatible withonClickhandler type. These are integration seams between independently-built modules.Comparison with v1
New issues filed
Takeaway
The use-case-oriented descriptions and decision trees measurably improved component selection — XDSLayout and XDSTopNav composition were correct from the start. The remaining gaps are about implicit behaviors (slots provide padding) rather than component discovery (which component to use). The fix pattern is the same: tell the LLM what it doesn't need to do, right where it'll read it.
feat(cli): rewrite theme command as interactive scaffold + add theme …
feat(cli): rewrite theme command as interactive scaffold + add theme …
docs(layout): improve descriptions for LLM discoverability (#198)
feat(cli): rewrite theme command as interactive scaffold + add theme …
docs(layout): improve descriptions for LLM discoverability (#198)
feat(cli): rewrite theme command as interactive scaffold + add theme …