Read this first, then read architecture.md for the detailed system map. Keep
this file focused on day-to-day orientation for agents; put durable architecture
details in architecture.md.
CSSX is the CSS toolchain used by StartupJS and usable on its own. Users write
css, styl, and optional pug templates with styleName and part props.
Babel compiles that authoring syntax into CSSX sheet IR plus runtime calls.
The unified @cssxjs/css-to-rn package owns CSS parsing, selector matching,
CSS variable resolution, CSS value evaluation, React Native/web style
transforms, runtime caching, provider themes, custom media, dimensions, and
React subscriptions.
- Read
architecture.mdbefore changing cross-package behavior. - Read
docs/guide/index.md,docs/guide/usage.md,docs/guide/component-parts.md,docs/guide/variables.md,docs/guide/theming.md, anddocs/examples/theme.mdfor the public model. - Use the package map below to choose the smallest code area to edit.
- Check
plan.mdonly for future/backlog items. Completed architecture should live inarchitecture.md, not inplan.md.
packages/css-to-rn/: unified compiler/runtime engine. Start here for CSS parsing, selector IR, value resolution, color functions, property transforms, caching,cssx(),useRuntimeCss(), variables, dimensions, provider themes, custom media, and React tracking.packages/cssxjs/: publiccssxjsfacade, package exports, CLI, runtime compatibility wrappers, Babel preset wrapper, loader wrappers, Metro wrappers, and built-in theme entrypoints such ascssxjs/themes/tailwindandcssxjs/themes/shadcn.packages/loaders/: Stylus/CSS loaders and direct compiler wrappers. Pure CSS compilation delegates to@cssxjs/css-to-rn; Stylus remains a separate preprocessing step.packages/babel-plugin-rn-stylename-inline/: compiles inlinecssandstyltemplates, including local template interpolation lowering.packages/babel-plugin-rn-stylename-to-style/: rewrites JSXstyleName,part, legacy*StyleName, imported style sheets, and helper calls into runtime calls.packages/babel-preset-cssxjs/: transform ordering and public Babel options.packages/bundler/: Metro hot-reload path for separate style files.packages/eslint-plugin-cssxjs/: wrapper around the React Pug ESLint processor.docs/: user-facing docs; update these when public behavior changes.example/: web demo using Babel plus esbuild.
__CSS_GLOBAL__and__CSS_LOCAL__connect the inline Babel plugin to the JSX/runtime plugin.- Runtime calls generated by Babel keep the compatibility shape
runtime(styleName, fileStyles, globalStyles, localStyles, inlineStyleProps). cssxjs/runtime/*wrappers adapt that call shape to the platform entrypoints exported by@cssxjs/css-to-rn.- Style priority is outer provider layers, inner provider layers, file/imported sheets, global templates, local templates, then inline props. Matching rules also sort by specificity and source order.
- Compiled sheets are JSON-serializable IR. Runtime cache, subscriptions, and dependency tracking must stay outside the sheet.
part='root'maps tostyle; other parts map to{partName}Style.:hover,:active,:part(hover), and:part(active)compile tohoverStyleandactiveStyle.- Component tag selectors such as
ButtonandButton:part(text)apply only inside components wrapped withthemed('Button', Component)or an explicit resolver tag option. - Provider/global
:rootcustom properties compile tosheet.rootVariables. Theme variables use:root.<theme>, for example:root.dark. CssxProviderlayers provider styles, root variables, custom media, and the active theme. At the root, nothemeprop uses the persisted global preference, ordefaultwhen no preference exists. Roottheme='auto'uses the system color scheme as the initial preference, then saved/user-selected preference takes priority.- CSSX reserves custom media names matching
--theme-*.@media (--theme-dark)is the standard way to write theme-specific rules. @custom-media --name (...)is supported in provider and component CSS. StartupJS UI uses breakpoint aliases such as--breakpoint-tablet.variablesanddefaultVariablesare validating proxies. Direct assignment/deletion works for valid--namekeys; bulk updates use.assign(),.set(), and.clear().- Local JS template interpolation is lowered to synthetic
var(--__cssx_dynamic_N)slots and passed asvalues. - Runtime CSS uses
useRuntimeCss(rawCss)pluscssx(styleName, sheet, inlineStyleProps)for dynamic client-side compilation. Variables come fromvariables,defaultVariables, provider:root, or template/layervalues. getCssColor()anduseCssColor()bridge CSS variables/colors into JS and return React Native-friendly values.useMedia()bridges CSSX custom media/media-query evaluation into JS.cache: 'teamplay'remains accepted as a Babel option for compatibility, but runtime caching is owned by@cssxjs/css-to-rn, not Teamplay.
Install dependencies:
yarn installRun all package tests:
yarn testRun targeted tests:
cd packages/css-to-rn && npm test
cd packages/css-to-rn && npm run test:types
cd packages/babel-plugin-rn-stylename-inline && yarn test
cd packages/babel-plugin-rn-stylename-to-style && yarn test
cd packages/loaders && yarn test
cd packages/cssxjs && npm testRun docs locally:
yarn docsRun the example app:
yarn start- Treat
AGENTS.mdandarchitecture.mdas living onboarding docs. If your change alters package boundaries, public APIs, build/runtime flow, commands, testing expectations, or maintenance rules, update these files in the same change before handing work back. - For CSS parsing, selector, value, transform, cache, variable, media, theme, or
React tracking behavior, update
packages/css-to-rn/test/engine/**orpackages/css-to-rn/test/react/**. - For inline template or interpolation compilation, update
packages/babel-plugin-rn-stylename-inlinesnapshots. - For JSX
styleName/partbehavior, updatepackages/babel-plugin-rn-stylename-to-stylesnapshots. - For public exports or wrapper behavior, update
packages/cssxjssmoke tests. - For public API or behavior changes, update
docs/,architecture.md, and this guide. - For Pug, type checking, or ESLint behavior, check whether the implementation
lives in
@react-pug/*; this repo often only wraps it. - For separate style files, check both Babel
compileCssImportsbehavior and Metro transformer behavior. - Prefer current source code and
docs/over older package READMEs when they conflict.