Vanilla Extract
Guides how to generate static CSS with Vanilla Extract in Lynx and use Crispy tokens.
Vanilla Extract extracts styles written in TypeScript to CSS at build time.
Define styles in .css.ts and apply the generated class names to the className of Lynx native elements.
You don't need to generate static styles in JavaScript every time they render.
Requirements and Installation
rspeedy-plugin-vanilla-extract adds Rspeedy-compatible processing to Vanilla Extract's webpack plugin.
This guide is based on the dependency conditions of the released plugin 0.2.0.
| Package | Condition |
|---|---|
@rsbuild/core | 1.x |
webpack | 5.x |
| Rspeedy and ReactLynx plugins | Versions compatible with the Rsbuild environment above |
First check which Rsbuild version your project's Rspeedy uses. The peer dependency of plugin 0.2.0 is @rsbuild/core: ^1.
Simply installing @rsbuild/core@1 on an Rsbuild 2-based project doesn't ensure compatibility.
If you're using Rsbuild 2, check the plugin version that supports it or refer to the Tailwind CSS 4 guide.
Install common Crispy packages from Installation, then add the following dependencies.
Rspeedy Configuration
Add pluginVanillaExtract({}) to the plugin list in your existing lynx.config.ts.
Keep existing ReactLynx plugin and Crispy feature flags configuration.
Import Crispy CSS
Importing the TypeScript reference for tokens alone does not declare the token values, so be sure to also load base.css.
In Lynx, use @seed-design/lynx-css instead of the web @seed-design/css.
For the color mode settings of the root <page>, refer to Theming.