# Vanilla Extract URL: /lynx/getting-started/styling/vanilla-extract Source: https://github.com/daangn/seed-design/blob/dev/docs/content/lynx/getting-started/styling/vanilla-extract.mdx 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](/lynx/getting-started/styling/tailwind-css-4). Install common Crispy packages from [Installation](/lynx/getting-started/installation), then add the following dependencies. - npm: npm install @vanilla-extract/css npm install -D rspeedy-plugin-vanilla-extract@0.2.0 @rsbuild/core@1 webpack@5 - pnpm: pnpm add @vanilla-extract/css pnpm add -D rspeedy-plugin-vanilla-extract@0.2.0 @rsbuild/core@1 webpack@5 - yarn: yarn add @vanilla-extract/css yarn add --dev rspeedy-plugin-vanilla-extract@0.2.0 @rsbuild/core@1 webpack@5 - bun: bun add @vanilla-extract/css bun add --dev rspeedy-plugin-vanilla-extract@0.2.0 @rsbuild/core@1 webpack@5 ## Rspeedy Configuration Add `pluginVanillaExtract({})` to the plugin list in your existing `lynx.config.ts`. Keep existing ReactLynx plugin and Crispy feature flags configuration. ```ts title="lynx.config.ts" import { defineConfig } from "@lynx-js/rspeedy"; import { pluginVanillaExtract } from "rspeedy-plugin-vanilla-extract"; export default defineConfig({ // ... existing configuration plugins: [ // ... existing plugins pluginVanillaExtract({}), ], }); ``` ## Import Crispy CSS ```css title="src/styles/global.css" @import "@seed-design/lynx-css/base.css"; ``` ```ts title="src/index.tsx" import "./styles/global.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 ``, refer to [Theming](/lynx/getting-started/styling/theming). ## Using Styles and Crispy Tokens ```ts title="src/App.css.ts" import { vars } from "@seed-design/lynx-css/vars"; import { style } from "@vanilla-extract/css"; export const root = style({ display: "flex", flexDirection: "column", rowGap: vars.$dimension.x2, padding: vars.$dimension.x4, backgroundColor: vars.$color.bg.layerDefault, borderRadius: vars.$radius.r3, }); export const label = style({ color: vars.$color.fg.neutral, fontSize: vars.$fontSize.t4, lineHeight: vars.$lineHeight.t4, fontWeight: vars.$fontWeight.medium, }); ``` ```tsx title="src/App.tsx" import * as styles from "./App.css"; export function App() { return ( First item Second item ); } ```