# 15-tailwind-css-and-design-tokens / app Tailwind v4 设计 token 工作台:`@theme` token、暗色变量覆盖、`nativeTheme` 联动、 CSP 与体积预算页。React 19 渲染,Tailwind 只进 renderer。 ## 运行 ```bash pnpm --filter @tutorial/15-tailwind-css-and-design-tokens-app start pnpm --filter @tutorial/15-tailwind-css-and-design-tokens-app smoke pnpm --filter @tutorial/15-tailwind-css-and-design-tokens-app shots ``` ## smoke 输出 ```json {"evt":"smoke","ok":true,"darkApplied":true,"lightApplied":true, "primary":"rgb(37, 99, 235)","tokens":8,"source":"light"} ``` ## 结构 - `src/styles/globals.css`:`@import "tailwindcss"` + `@theme` + `.dark` 覆盖 - `src/App.tsx`:token / 暗色 / CSP 三个页签 - `main/`:`nativeTheme` 读写与广播、smoke/shots - `preload/`:只暴露 `theme.get/set/onChange` - `vite.renderer.config.mts`:react + `@tailwindcss/vite`(仅 renderer) ## testid | testid | 用途 | | --- | --- | | `app-title` | 页面标题 | | `tab-tokens` / `tab-dark` / `tab-csp` | 三个页签 | | `theme-system` / `theme-light` / `theme-dark` | 主题切换 | | `dark-state` | 当前是否暗色 | | `primary-button` | 主按钮(颜色 token) | | `css-gzip` | 生产 CSS gzip 值 | ## 已知限制 - 只在 macOS arm64 验证;暗色系统跟随依赖 `nativeTheme`。 - 体积数字来自 demo-03 的本地构建,升级 Tailwind 后需重测。