StyleX and CSS integration
StyleX recipes are the default for styling markup controlled by Astryx. Use
stylex. token groups for shared values and stylex. recipes for component
layout, typography, color, responsive behavior, state and variants. A token defines a value; it
does not apply that value to an element. Fluid templates apply compiled recipes through the
ax: ViewHelper.
Avoid hand-authored CSS for ordinary component styling. A block-specific selector is not by itself a reason to create a CSS file, and an existing CSS import does not mean its declarations need to remain in CSS. Prefer migrating controlled block and preview markup to StyleX recipes that consume the shared tokens.
Use CSS only for a concrete browser or integration requirement that the pinned StyleX compiler and
the current Fluid/build path cannot express or reliably apply. Keep each exception small, scoped to
its integration surface, and documented beside the source. Use existing -- variables in
CSS; do not maintain a parallel set of design values in CSS. Any deliberate override of a public
token must be a narrow, documented integration contract.
Source of truth and quick routing
Paths in this table are relative to the typo3_ extension root unless marked
astryx_.
| Change | Authored source |
|---|---|
| Text, surface, border, accent or status color | Resources/ |
| Category palette colors | Resources/ |
| Code surface and syntax colors | Resources/ |
| Typography, spacing, layout, shape, shadow or motion | The matching Resources/ |
| Deliberately themeable component contract | Resources/ |
| Built-in theme override | Resources/ |
| Reusable component or page-chrome styling | Resources/ |
| Recipe used by one Content Block only | Content |
| Site-only component or product styling | astryx_ |
| Rich-text HTML styling | Resources/; keep rules scoped to .ck- or
.astryx- and use shared tokens |
| Native dialog backdrop | Resources/ |
| Single-column no-JavaScript browser fallback | Content |
Build/ is the registry for token families and built-in themes. Add a new
token family there and add its define module to
Resources/ so RTE and preview builds include the
variable group. Public CSS custom properties use the -- prefix and lowercase kebab-case
semantic names, for example -- or
--. Name a value for its role, not its current hex,
theme, mode or incidental selector. Keep one-off values inside the recipe that uses them.
Use a component token family only when its values form a deliberate, reusable themeable contract.
Keep implementation-only custom properties private to their component or block, with a local name
that does not use the public -- namespace.
Recipe files use lowercase kebab-case and the .stylex. suffix. Keep every basename unique in
the generated manifest because Fluid-facing aliases are derived from the basename; changing a
basename can therefore require changing template keys. Keep recipe keys finite and synchronize
Build/, Classes/ and Fluid recipe choices.
Never put StyleX compiler input under a Content Block's published assets/ folder.
Theme identity and color mode
Theme identity and color mode are separate choices. The built-in identities are neutral,
stone and ocean; modes are system, light and dark. Keep mode and theme out of
token names. A semantic role such as -- keeps the same contract in each
theme. Color roles that vary only by mode use CSS light- values and the resolved
color-.
Theme source modules use stylex. to override the relevant token groups. Overrides
may be sparse; Build/ reads the registered defaults and overrides and
emits complete token sets at each theme boundary. This prevents nested themes, RTE content and
backend previews from depending on an unrelated ancestor's variables. Do not edit the generated
Build/ or Resources/.
Adding a theme updates the StyleX source and the TYPO3 runtime allowlist together:
- Add
Resources/and import only the token groups it overrides.Private/ Java Script/ Style X/ themes/<name>- theme. stylex. js - Register the lowercase identity and source file in
Build/.design- tokens. json - Import the theme module from
Resources/.Private/ Java Script/ frontend. entry. js - Add the same identity to
Classes/and the page field choices inConfiguration/ Theme Resolver. php Configuration/. Add its label toTCA/ Overrides/ pages. php Resources/and update Configuration.Private/ Language/ locallang. xlf - Regenerate the bridge and build the extension. Verify the theme in light/dark modes and at
nested boundaries in the frontend, RTE and backend preview. Record upstream source and local
adaptations in
Build/,upstream- versions. json Build/andadaptations. json THIRD_when applicable.PARTY_ NOTICES. md
Consumer branding should use a deliberate existing theme contract or site-owned StyleX recipe
where that fits. Do not copy the extension's token files into the sitepackage. A global CSS
override is an exception: use it only for a specific integration surface the current StyleX path
cannot express, and record the limitation. The sitepackage's Resources/ is
currently a declaration-free @layer product; anchor for Vite, not a place for component rules.
CSS policy and current exceptions
These are the CSS sources currently connected to the extension build. This list describes the existing integration boundaries; it is not a recommendation to add more CSS.
| Source | Role and rule | Included by |
|---|---|---|
Resources/ | Import aggregator only. Do not add component or page rules. | Resources/ |
Resources/ | CSS-only foundation imports for layers, fonts, reset, generated theme variables and prose. | Frontend aggregator, RTE entry and preview entry |
Resources/ | Reuses the RTE foundation; preview component layout is StyleX. | Resources/ |
Resources/ | Declares cascade-layer order. Keep the ordering contract; do not add component rules. | rte. |
Resources/ | @font- registration for packaged font files. | rte. |
Resources/ | Scoped baseline and broad reduced-motion/forced-colors rules for arbitrary CMS and browser-owned markup. | rte. |
Resources/ | Semantic descendants of CKEditor and arbitrary rich-text/prose HTML. Scope these rules and use StyleX token variables for design values. | rte. |
Resources/ | :: for the native dialog; StyleX 0.19 does not compile pseudo-elements. | main. |
Resources/ | Generated theme variable bridge. Never edit by hand. | Generated by Build/; imported by rte. |
Content | @property sizing and ancestor :has query-container fallback for full-bleed layout
before JavaScript enhancement. Keep only these browser-level declarations here. | main. |
| Block preview recipes | Controlled preview wrappers and parts are StyleX; there are no per-block preview CSS files. | backend- imports each src/*- module |
The Content Block src/ directory is the private source location for a block-owned recipe and
for a justified block-specific CSS exception. It is not a reason to use CSS: layout, spacing,
colors, responsive behavior, states and variants for controlled markup belong in a StyleX recipe.
Add a CSS import only after documenting the specific browser or integration requirement and why a
recipe cannot handle it. Keep the CSS beside its owner, preserve required cascade layers, and use
existing public tokens in its declarations.
How the entrypoints connect
The extension uses separate Vite entries because frontend, CKEditor and TYPO3 backend preview consume different combinations of styles:
frontend.entry.js
└── CSS/main.css
├── CSS/rte.entry.css
│ ├── layers.css
│ ├── fonts.css
│ ├── reset.css
│ ├── themes.css (generated)
│ └── prose.css
├── CSS/navigation-backdrop.css
└── container-single-col/src/container-single-col.css
├── shared StyleX component/page recipes
├── ContentBlocks/*/src/*.stylex.js frontend recipes
└── StyleX/themes/*-theme.stylex.js
rte-editor.entry.js
├── CSS/rte.entry.css
└── StyleX/tokens/index.js
backend-preview.entry.js
├── CSS/preview.entry.css → CSS/rte.entry.css
├── StyleX/tokens/index.js
├── shared preview/media recipes
└── ContentBlocks/*/src/*-preview.stylex.js recipes
Style is a side-effect barrel for token modules. The editor/preview builds
include these declarations with their CSS foundations. Import a frontend recipe from
frontend.; import a preview recipe from backend-. A source that is
not reachable from its Vite entry is not compiled. Keep the frontend and backend preview class
requirements in their correct entrypoints and manifest.
The sitepackage imports its site-owned StyleX recipe from site.. Its CSS main.
only declares the Vite layer anchor. Keep site-specific rules in the site-owned StyleX recipe and
use the shared extension entry/asset integration rather than adding another asset include for the
same compiled CSS.
Generated assets and TYPO3 links
Generated CSS and manifests are outputs from the token bridge, StyleX/Vite compiler and finalizer. Edit authored tokens, recipes, CSS exceptions or entry imports; never hand-edit generated class names, CSS bundles, manifests or checksums.
| Generated file | Runtime link |
|---|---|
Resources/ and Build/ | Bridge outputs generated from define, registered create overrides and
Build/. |
Resources/ and astryx. | Packaged frontend output loaded by Page when Vite mode
is disabled. |
Resources/ | Generated RTE stylesheet linked by Configuration/ through
editor.. |
Resources/ | Generated preview stylesheet linked by Content Block backend-preview templates using
<f:. |
Resources/ and preview. | Generated paired Vite CSS artifacts retained and checksummed by the StyleX manifest/build contract. |
Resources/ | Generated key-to-class mapping and artifact checksums consumed by the StyleX Connector. |
When Astryx., Astryx loads the registered extension
frontend. through vite: and the consuming project's Vite manifest supplies
the asset URLs. Otherwise, the layout loads packaged astryx. and astryx.. Select one
path for the extension frontend; do not load both. The RTE and preview use their separate
generated stylesheets as configured above.
Build and verification
From typo3-, regenerate tokens before the full build after changing token or theme
sources, then let the build regenerate paired CSS, JS and manifests:
ddev exec node packages/typo3_astryx/Build/generate-theme-bridge.mjs
ddev exec npm run build
ddev exec node packages/typo3_astryx/Build/verify-style-ownership.mjs
ddev exec node packages/typo3_astryx/Build/verify-artifacts.mjs
Run ddev exec vendor/ when a recipe or
manifest key changes. Flush TYPO3 caches after manifest classes or rendered settings change. Keep
the CSS and matching StyleX manifest from one successful build together when deploying.
Related guidance: Styling, Theme strategy and Configuration.