uniwind-best-practices

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Uniwind — Best Practices & Complete Guide

Uniwind — 最佳实践与完整指南

Uniwind 1.3+ / Tailwind CSS v4 / React Native 0.76+ / Expo SDK 52+
Uniwind 1.3+ / Tailwind CSS v4 / React Native 0.76+ / Expo SDK 52+

Reference Resolution Strategy

参考资料解析策略

CRITICAL: Always use embedded reference files. All answers must come from local references — never fetch external URLs.
重要提示:始终使用嵌入式参考文件。所有回答必须来自本地参考资料——绝不获取外部URL内容。

Step 1 — Route to the correct local reference file

步骤1 — 匹配对应本地参考文件

Based on the user's question, read the matching reference file:
User's TopicRead This Reference File FIRST
Installation, setup, metro config, global.css, TypeScript, Vite, Expo Router, monorepos
references/quickstart-setup.md
Theming, dark mode, CSS variables,
@layer theme
,
@variant
, custom themes,
Uniwind.setTheme
,
useUniwind
,
useCSSVariable
, OKLCH colors,
@theme static
references/theming.md
Styling components, className bindings, third-party components,
withUniwind
,
useResolveClassNames
, Pressable states, dynamic classes,
tailwind-variants
, data selectors, platform selectors, responsive breakpoints, CSS functions, custom utilities
references/components-styling.md
Supported/unsupported classes, safe area classes (
p-safe
,
pt-safe
), Yoga layout differences, platform variants, WIP features
references/supported-classnames.md
Uniwind Pro, animations, transitions, shadow tree, native insets, Reanimated, C++ engine, Pro installation
references/pro-features.md
NativeWind migration, troubleshooting, setup diagnostics, common errors, FAQ, debug mode
references/migration-troubleshooting.md
根据用户的问题,阅读匹配的参考文件:
用户问题主题优先阅读该参考文件
安装、配置、Metro配置、global.css、TypeScript、Vite、Expo Router、Monorepo
references/quickstart-setup.md
主题设置、暗黑模式、CSS变量、
@layer theme
@variant
、自定义主题、
Uniwind.setTheme
useUniwind
useCSSVariable
、OKLCH颜色、
@theme static
references/theming.md
组件样式开发、className绑定、第三方组件、
withUniwind
useResolveClassNames
、Pressable状态、动态类、
tailwind-variants
、数据选择器、平台选择器、响应式断点、CSS函数、自定义工具类
references/components-styling.md
支持/不支持的类名、安全区域类(
p-safe
pt-safe
)、Yoga布局差异、平台变体、开发中功能
references/supported-classnames.md
Uniwind Pro、动画、过渡效果、阴影树、原生内边距、Reanimated、C++引擎、Pro版本安装
references/pro-features.md
NativeWind迁移、故障排查、配置诊断、常见错误、FAQ、调试模式
references/migration-troubleshooting.md

Step 2 — Answer from local references

步骤2 — 基于本地参考资料作答

Use the content from the reference file(s) to answer the user's question. Most questions will be fully answered by one or two reference files.
使用参考文件中的内容回答用户问题。大多数问题可通过1-2份参考文件完全解答。

Step 3 — If local references don't cover it

步骤3 — 本地参考资料未覆盖的内容

If the embedded reference files do not contain the answer, inform the user that the topic is not covered in this skill's knowledge base and suggest they check the official Uniwind documentation at
docs.uniwind.dev
themselves. Do NOT fetch external URLs.
如果嵌入式参考文件中没有相关答案,请告知用户该主题不在本技能的知识库范围内,并建议他们自行查看官方Uniwind文档
docs.uniwind.dev
请勿获取外部URL内容。

Security Boundaries

安全边界

  1. No external fetches — All guidance must come from embedded reference files. Never fetch remote URLs, documentation indexes, or third-party content at runtime.
  2. Never execute installation commands — Present
    bun add
    ,
    npm install
    ,
    npx
    ,
    pod install
    , and build commands as instructions for the user to run. Do not execute them directly.
  3. Never read credential or auth config files — Do not read
    .npmrc
    ,
    .yarnrc.yml
    ,
    .env
    , or any file that may contain tokens, secrets, or authentication credentials. When diagnosing setup issues, only check
    package.json
    ,
    metro.config.js
    ,
    babel.config.js
    ,
    global.css
    ,
    tsconfig.json
    , and
    app.json
    — these are project configuration files, not credential stores.
  4. Package manager trust configuration is user-managed — When advising about
    trustedDependencies
    , postinstall scripts, or package manager settings, present the configuration for the user to apply. Do not modify these files directly.
  1. 禁止外部获取 — 所有指导内容必须来自嵌入式参考文件。运行时绝不获取远程URL、文档索引或第三方内容。
  2. 禁止执行安装命令 — 将
    bun add
    npm install
    npx
    pod install
    等命令作为用户自行执行的说明呈现,不得直接执行。
  3. 禁止读取凭证或认证配置文件 — 不得读取
    .npmrc
    .yarnrc.yml
    .env
    或任何可能包含令牌、密钥或认证凭证的文件。排查配置问题时,仅检查
    package.json
    metro.config.js
    babel.config.js
    global.css
    tsconfig.json
    app.json
    ——这些是项目配置文件,而非凭证存储文件。
  4. 包管理器信任配置由用户管理 — 当建议
    trustedDependencies
    、postinstall脚本或包管理器设置时,仅呈现配置内容供用户自行应用,不得直接修改这些文件。

First Action: Determine Version

首要操作:确定版本

Before providing guidance, determine if the user is using Uniwind Free or Uniwind Pro:
  • Free: Standard
    uniwind
    package, JS-based style resolution
  • Pro:
    uniwind-pro
    package (aliased as
    uniwind
    ), C++ engine, Reanimated animations, shadow tree updates, native insets
Ask: "Are you using Uniwind Free or Uniwind Pro?" — this changes available features and troubleshooting steps.
提供指导前,需确定用户使用的是Uniwind免费版还是Uniwind Pro版
  • 免费版:标准
    uniwind
    包,基于JS的样式解析
  • Pro版
    uniwind-pro
    包(别名
    uniwind
    ),C++引擎、Reanimated动画、阴影树更新、原生内边距
询问用户:“您使用的是Uniwind免费版还是Pro版?”——这会影响可用功能和故障排查步骤。

Setup Diagnostic Workflow

配置诊断流程

When the user reports setup issues, styles not applying, or asks to check their config, read only these project configuration files (never read
.npmrc
,
.yarnrc.yml
,
.env
, or other files that may contain credentials):
当用户反馈配置问题、样式不生效或要求检查配置时,仅读取以下项目配置文件(绝不读取
.npmrc
.yarnrc.yml
.env
或其他可能包含凭证的文件):

1. Check package.json

1. 检查package.json

- "uniwind" or "uniwind-pro" must be in dependencies
- "tailwindcss" must be v4+ (^4.0.0)
- For Pro: "react-native-nitro-modules", "react-native-reanimated", "react-native-worklets" required
- dependencies中必须包含`uniwind`或`uniwind-pro`
- `tailwindcss`版本必须为v4+(^4.0.0)
- Pro版需依赖:`react-native-nitro-modules`、`react-native-reanimated`、`react-native-worklets`

2. Check metro.config.js

2. 检查metro.config.js

- Must import { withUniwindConfig } from 'uniwind/metro'
- withUniwindConfig MUST be the OUTERMOST wrapper
- cssEntryFile must be a RELATIVE path string (e.g., './src/global.css')
- Never use path.resolve() or absolute paths for cssEntryFile
- 必须从'uniwid/metro'导入`{ withUniwindConfig }`
- withUniwindConfig必须是**最外层**的包装器
- cssEntryFile必须是相对路径字符串(例如:'./src/global.css')
- 绝不对cssEntryFile使用path.resolve()或绝对路径

3. Check global.css

3. 检查global.css

- Must contain: @import 'tailwindcss'; AND @import 'uniwind';
- Must be imported in App.tsx or root layout, NOT in index.ts/index.js
- Location determines app root — Tailwind scans from this directory
- 必须包含:@import 'tailwindcss'; 和 @import 'uniwind';
- 必须在App.tsx或根布局中导入,不可在index.ts/index.js中导入
- 文件位置决定应用根目录——Tailwind会从该目录开始扫描

4. Check babel.config.js (Pro only)

4. 检查babel.config.js(仅Pro版)

- Must include 'react-native-worklets/plugin' in plugins array
- plugins数组中必须包含'react-native-worklets/plugin'

5. Check TypeScript config

5. 检查TypeScript配置

- uniwind-types.d.ts should be included in tsconfig.json or placed in src/app dir
- Run Metro server to auto-generate types
- uniwind-types.d.ts应包含在tsconfig.json中,或放置在src/app目录下
- 运行Metro服务器可自动生成类型文件

Common Setup Errors

常见配置错误

SymptomCauseFix
Styles not applyingMissing
@import 'uniwind'
in global.css
Add both imports
Styles not applyingglobal.css imported in index.jsMove import to App.tsx or _layout.tsx
Classes not detectedglobal.css in nested dir, components elsewhereAdd
@source '../components'
TypeScript errorsMissing types fileRun Metro to generate uniwind-types.d.ts
Hot reload brokenglobal.css in index.tsMove to App.tsx
Metro crashAbsolute path in cssEntryFileUse relative:
'./src/global.css'
withUniwindConfig not outermostOther wrapper wraps UniwindSwap order so Uniwind is outermost
Pro animations brokenMissing Babel pluginAdd
react-native-worklets/plugin
Pro not workingMissing native rebuildRun
npx expo prebuild --clean
then
expo run:ios
Pro postinstall failedPackage manager blocks scriptsAdvise user to whitelist in
trustedDependencies
(bun) — see pro-features.md
症状原因修复方案
样式不生效global.css中缺少
@import 'uniwind'
添加两个import语句
样式不生效global.css在index.js中导入将导入移至App.tsx或_layout.tsx
类名未被检测到global.css在嵌套目录中,组件位于其他位置添加
@source '../components'
TypeScript报错缺少类型文件运行Metro生成uniwind-types.d.ts
热重载失效global.css在index.ts中导入移至App.tsx
Metro崩溃cssEntryFile使用绝对路径使用相对路径:
'./src/global.css'
withUniwindConfig不是最外层其他包装器包裹了Uniwind调整顺序,让Uniwind作为最外层包装
Pro版动画失效缺少Babel插件添加
react-native-worklets/plugin
Pro版无法工作未重建原生代码运行
npx expo prebuild --clean
,然后执行
expo run:ios
Pro版postinstall失败包管理器阻止脚本执行建议用户在
trustedDependencies
中加入白名单(bun)——详见pro-features.md

Critical Rules

核心规则

  1. Tailwind v4 only — Uniwind does not support Tailwind v3. Use
    @import 'tailwindcss'
    (not
    @tailwind base
    ).
  2. Never construct classNames dynamically — Use complete string literals. Tailwind scans at build time.
  3. Never use
    cssInterop
    — Uniwind does not override global components like NativeWind.
  4. No
    tailwind.config.js
    needed
    — All config is in
    global.css
    via
    @theme
    and
    @layer theme
    .
  5. No ThemeProvider required — Use
    Uniwind.setTheme()
    directly.
  6. withUniwindConfig must be outermost Metro config wrapper.
  7. @theme
    variables only affect styled components
    <Text>
    without className uses RN defaults.
  8. Font families: single font only — No fallbacks in RN.
    --font-sans: 'Roboto-Regular'
    not
    'Roboto', sans-serif
    .
  9. rem default is 16px — NativeWind used 14px. Configure
    polyfills: { rem: 14 }
    if migrating.
  1. 仅支持Tailwind v4 — Uniwind不支持Tailwind v3。使用
    @import 'tailwindcss'
    (而非
    @tailwind base
    )。
  2. 禁止动态拼接className — 使用完整的字符串字面量。Tailwind在构建时扫描类名。
  3. 禁止使用
    cssInterop
    — Uniwind不会像NativeWind那样覆盖全局组件。
  4. 无需
    tailwind.config.js
    — 所有配置通过
    global.css
    中的
    @theme
    @layer theme
    实现。
  5. 无需ThemeProvider — 直接使用
    Uniwind.setTheme()
  6. withUniwindConfig必须是Metro配置的最外层包装器
  7. @theme
    变量仅影响带样式的组件
    — 未设置className的
    <Text>
    会使用RN默认样式。
  8. 字体族:仅支持单个字体 — RN不支持回退字体。使用
    --font-sans: 'Roboto-Regular'
    而非
    'Roboto', sans-serif
  9. rem默认值为16px — NativeWind使用14px。如果是迁移项目,可配置
    polyfills: { rem: 14 }

Core Patterns

核心模式

Styling Components

组件样式开发

tsx
import { View, Text, Pressable } from 'react-native'

<View className="flex-1 bg-background p-4">
  <Text className="text-foreground text-lg font-bold">Title</Text>
  <Pressable className="bg-primary px-6 py-3 rounded-lg active:opacity-80">
    <Text className="text-white text-center font-semibold">Button</Text>
  </Pressable>
</View>
tsx
import { View, Text, Pressable } from 'react-native'

<View className="flex-1 bg-background p-4">
  <Text className="text-foreground text-lg font-bold">标题</Text>
  <Pressable className="bg-primary px-6 py-3 rounded-lg active:opacity-80">
    <Text className="text-white text-center font-semibold">按钮</Text>
  </Pressable>
</View>

Dynamic Classes (Correct Way)

动态类(正确方式)

tsx
// Map objects with complete class names
const variants = {
  primary: 'bg-blue-500 text-white',
  danger: 'bg-red-500 text-white',
  ghost: 'bg-transparent text-foreground',
}
<Pressable className={variants[variant]} />

// Ternary with complete strings
<View className={isActive ? 'bg-primary' : 'bg-muted'} />

// tailwind-variants for complex components
import { tv } from 'tailwind-variants'
const button = tv({
  base: 'font-semibold rounded-lg px-4 py-2',
  variants: {
    color: { primary: 'bg-blue-500 text-white', secondary: 'bg-gray-500 text-white' },
    size: { sm: 'text-sm', md: 'text-base', lg: 'text-lg' },
  },
  defaultVariants: { color: 'primary', size: 'md' },
})
<Pressable className={button({ color: 'primary', size: 'lg' })} />
tsx
// 使用包含完整类名的映射对象
const variants = {
  primary: 'bg-blue-500 text-white',
  danger: 'bg-red-500 text-white',
  ghost: 'bg-transparent text-foreground',
}
<Pressable className={variants[variant]} />

// 使用完整字符串的三元表达式
<View className={isActive ? 'bg-primary' : 'bg-muted'} />

// 复杂组件使用tailwind-variants
import { tv } from 'tailwind-variants'
const button = tv({
  base: 'font-semibold rounded-lg px-4 py-2',
  variants: {
    color: { primary: 'bg-blue-500 text-white', secondary: 'bg-gray-500 text-white' },
    size: { sm: 'text-sm', md: 'text-base', lg: 'text-lg' },
  },
  defaultVariants: { color: 'primary', size: 'md' },
})
<Pressable className={button({ color: 'primary', size: 'lg' })} />

Third-Party Components

第三方组件

tsx
// withUniwind — wrap once, use everywhere (recommended)
import { withUniwind } from 'uniwind'
import { SafeAreaView } from 'react-native-safe-area-context'
const StyledSafeArea = withUniwind(SafeAreaView)
<StyledSafeArea className="flex-1 bg-background" />

// useResolveClassNames — one-off usage
import { useResolveClassNames } from 'uniwind'
const styles = useResolveClassNames('bg-blue-500 p-4 rounded-lg')
<ThirdPartyComponent style={styles} />
tsx
// withUniwind — 包裹一次,全局可用(推荐)
import { withUniwind } from 'uniwind'
import { SafeAreaView } from 'react-native-safe-area-context'
const StyledSafeArea = withUniwind(SafeAreaView)
<StyledSafeArea className="flex-1 bg-background" />

// useResolveClassNames — 一次性使用
import { useResolveClassNames } from 'uniwind'
const styles = useResolveClassNames('bg-blue-500 p-4 rounded-lg')
<ThirdPartyComponent style={styles} />

Theming

主题设置

Quick Setup (light/dark only)

快速配置(仅浅色/深色模式)

tsx
// Just use dark: prefix — works out of the box
<View className="bg-white dark:bg-gray-900">
  <Text className="text-black dark:text-white">Themed</Text>
</View>
tsx
// 直接使用dark:前缀——开箱即用
<View className="bg-white dark:bg-gray-900">
  <Text className="text-black dark:text-white">主题化内容</Text>
</View>

Scalable Setup (CSS variables)

可扩展配置(CSS变量)

Define in
global.css
, reference as utilities without
dark:
prefix:
css
/* global.css */
@import 'tailwindcss';
@import 'uniwind';

@layer theme {
  :root {
    @variant light {
      --color-background: #ffffff;
      --color-foreground: #000000;
      --color-primary: #3b82f6;
      --color-card: #ffffff;
      --color-border: #e5e7eb;
    }
    @variant dark {
      --color-background: #000000;
      --color-foreground: #ffffff;
      --color-primary: #3b82f6;
      --color-card: #1f2937;
      --color-border: #374151;
    }
  }
}
tsx
// Auto-adapts to current theme — no dark: prefix needed
<View className="bg-background border border-border p-4 rounded-lg">
  <Text className="text-foreground">Themed card</Text>
</View>
global.css
中定义,无需dark:前缀即可引用工具类:
css
/* global.css */
@import 'tailwindcss';
@import 'uniwind';

@layer theme {
  :root {
    @variant light {
      --color-background: #ffffff;
      --color-foreground: #000000;
      --color-primary: #3b82f6;
      --color-card: #ffffff;
      --color-border: #e5e7eb;
    }
    @variant dark {
      --color-background: #000000;
      --color-foreground: #ffffff;
      --color-primary: #3b82f6;
      --color-card: #1f2937;
      --color-border: #374151;
    }
  }
}
tsx
// 自动适配当前主题——无需dark:前缀
<View className="bg-background border border-border p-4 rounded-lg">
  <Text className="text-foreground">主题化卡片</Text>
</View>

Theme Switching

主题切换

tsx
import { Uniwind, useUniwind } from 'uniwind'

Uniwind.setTheme('dark')     // Switch to dark
Uniwind.setTheme('light')    // Switch to light
Uniwind.setTheme('system')   // Follow device

const { theme, hasAdaptiveThemes } = useUniwind() // Reactive hook
tsx
import { Uniwind, useUniwind } from 'uniwind'

Uniwind.setTheme('dark')     // 切换到深色模式
Uniwind.setTheme('light')    // 切换到浅色模式
Uniwind.setTheme('system')   // 跟随系统设置

const { theme, hasAdaptiveThemes } = useUniwind() // 响应式钩子

Custom Themes

自定义主题

Require
extraThemes
in metro.config.js and
@variant
in global.css. See references/theming.md for complete custom theme setup.
需要在metro.config.js中配置
extraThemes
,并在global.css中使用
@variant
。完整的自定义主题配置详见references/theming.md

Platform Selectors

平台选择器

tsx
<View className="ios:pt-12 android:pt-6 web:pt-4" />
<View className="native:bg-blue-500 web:bg-gray-500" />  // native = iOS + Android
Platform media queries in
@theme
for global values:
css
@layer theme {
  :root {
    @media ios { --font-sans: "SF Pro Text"; }
    @media android { --font-sans: "Roboto-Regular"; }
  }
}
tsx
<View className="ios:pt-12 android:pt-6 web:pt-4" />
<View className="native:bg-blue-500 web:bg-gray-500" />  // native = iOS + Android
@theme
中使用平台媒体查询定义全局值:
css
@layer theme {
  :root {
    @media ios { --font-sans: "SF Pro Text"; }
    @media android { --font-sans: "Roboto-Regular"; }
  }
}

Data Selectors

数据选择器

Style based on prop values —
data-[prop=value]:utility
:
tsx
<Pressable
  data-selected={isSelected}
  className="border rounded px-3 py-2 data-[selected=true]:ring-2 data-[selected=true]:ring-primary"
/>
Only equality checks supported. Boolean and string values work.
根据属性值设置样式——
data-[prop=value]:utility
tsx
<Pressable
  data-selected={isSelected}
  className="border rounded px-3 py-2 data-[selected=true]:ring-2 data-[selected=true]:ring-primary"
/>
仅支持相等性检查,布尔值和字符串值均适用。

Responsive Breakpoints

响应式断点

Mobile-first:
sm:
(640px),
md:
(768px),
lg:
(1024px),
xl:
(1280px),
2xl:
(1536px).
tsx
<View className="p-4 sm:p-6 lg:p-8">
  <Text className="text-base sm:text-lg lg:text-xl">Responsive</Text>
</View>
Custom breakpoints via
@theme { --breakpoint-tablet: 820px; }
.
移动端优先:
sm:
(640px)、
md:
(768px)、
lg:
(1024px)、
xl:
(1280px)、
2xl:
(1536px)。
tsx
<View className="p-4 sm:p-6 lg:p-8">
  <Text className="text-base sm:text-lg lg:text-xl">响应式内容</Text>
</View>
可通过
@theme { --breakpoint-tablet: 820px; }
自定义断点。

CSS Functions

CSS函数

Define as
@utility
in global.css, not directly in className:
css
@utility h-hairline { height: hairlineWidth(); }
@utility text-scaled { font-size: fontScale(); }
@utility bg-adaptive { background-color: light-dark(#ffffff, #1f2937); }
需在global.css中定义为
@utility
,不可直接在className中使用:
css
@utility h-hairline { height: hairlineWidth(); }
@utility text-scaled { font-size: fontScale(); }
@utility bg-adaptive { background-color: light-dark(#ffffff, #1f2937); }

Uniwind Pro Features

Uniwind Pro版功能

Only available with
uniwind-pro
package. Ask user first.
uniwind-pro
包可用。请先询问用户版本。

Reanimated Animations (Pro)

Reanimated动画(Pro版)

tsx
// Keyframe animations — just add className
<View className="animate-spin" />
<View className="animate-bounce" />
<View className="animate-pulse" />

// Transitions — smooth property changes
<Pressable className="bg-blue-500 active:bg-blue-600 transition-colors duration-300" />
<View className={`transition-opacity duration-500 ${visible ? 'opacity-100' : 'opacity-0'}`} />
<Pressable className="active:scale-95 transition-transform duration-150" />
Components auto-swap to Animated versions when animation classes detected.
tsx
// 关键帧动画——只需添加className
<View className="animate-spin" />
<View className="animate-bounce" />
<View className="animate-pulse" />

// 过渡效果——平滑的属性变化
<Pressable className="bg-blue-500 active:bg-blue-600 transition-colors duration-300" />
<View className={`transition-opacity duration-500 ${visible ? 'opacity-100' : 'opacity-0'}`} />
<Pressable className="active:scale-95 transition-transform duration-150" />
检测到动画类名时,组件会自动替换为Animated版本。

Shadow Tree Updates (Pro)

阴影树更新(Pro版)

No code changes required — props connect directly to C++ engine, eliminating re-renders.
无需修改代码——属性直接连接到C++引擎,消除重渲染。

Native Insets (Pro)

原生内边距(Pro版)

No
SafeAreaListener
setup needed — insets injected from native layer automatically.
无需设置
SafeAreaListener
——内边距会自动从原生层注入。

HeroUI Native Integration

HeroUI Native集成

HeroUI Native uses Uniwind (Tailwind v4 via Uniwind). Apply these patterns:
  • Use
    className
    prop directly on HeroUI Native components
  • Theme tokens from global.css work with HeroUI components
  • Use
    tailwind-variants
    (tv) for variant-based component styling — HeroUI uses this internally
  • Wrap any HeroUI component lacking className support with
    withUniwind()
  • Use semantic color tokens (
    bg-primary
    ,
    text-foreground
    ) for theme consistency
HeroUI Native基于Uniwind(通过Uniwind适配Tailwind v4)构建。应用以下模式:
  • 直接在HeroUI Native组件上使用
    className
    属性
  • global.css中的主题令牌可在HeroUI组件中生效
  • 使用
    tailwind-variants
    (tv)实现基于变体的组件样式——HeroUI内部也采用此方式
  • 对不支持className的HeroUI组件,使用
    withUniwind()
    包裹
  • 使用语义化颜色令牌(
    bg-primary
    text-foreground
    )保证主题一致性

Code Review & Audit

代码评审与审计

When asked to review Uniwind code, check:
  • global.css has both
    @import 'tailwindcss'
    and
    @import 'uniwind'
  • withUniwindConfig is outermost Metro wrapper
  • cssEntryFile is relative path
  • No dynamic className construction (template literals, string concat)
  • All theme variants define the same CSS variables
  • Using semantic color tokens, not hardcoded colors
  • Third-party components wrapped with
    withUniwind
    or use
    useResolveClassNames
  • Platform differences handled with
    ios:/android:/native:
    not
    Platform.select()
  • Mobile-first responsive design (base styles + sm: md: lg: enhancements)
  • Font families are single values (no fallback arrays)
  • @theme
    variables customized via CSS, not tailwind.config.js
当被要求评审Uniwind代码时,检查以下内容:
  • global.css同时包含
    @import 'tailwindcss'
    @import 'uniwind'
  • withUniwindConfig是Metro配置的最外层包装器
  • cssEntryFile使用相对路径
  • 无动态拼接className的操作(模板字面量、字符串拼接)
  • 所有主题变体定义了相同的CSS变量
  • 使用语义化颜色令牌,而非硬编码颜色
  • 第三方组件已用
    withUniwind
    包裹或使用
    useResolveClassNames
  • 使用
    ios:/android:/native:
    处理平台差异,而非
    Platform.select()
  • 采用移动端优先的响应式设计(基础样式 + sm: md: lg: 增强)
  • 字体族为单个值(无回退数组)
  • 通过CSS自定义
    @theme
    变量,而非使用tailwind.config.js

Reference Files (Read BEFORE External Docs)

参考文件(优先于外部文档)

These files are your primary source of truth. Read the relevant file(s) before answering any Uniwind question.
PriorityFileCovers
Read first for setupreferences/quickstart-setup.mdInstallation, Metro config, global.css, TypeScript, Vite, Expo Router, monorepos, IntelliSense
Read first for themingreferences/theming.mdLight/dark, custom themes, CSS variables,
@layer theme
,
@variant
,
Uniwind.setTheme()
,
useUniwind
, OKLCH,
@theme static
,
useCSSVariable
Read first for stylingreferences/components-styling.mdRN component bindings,
withUniwind
,
useResolveClassNames
, Pressable states, dynamic classes,
tailwind-variants
, data selectors, platform selectors, responsive breakpoints, CSS functions
Read first for class supportreferences/supported-classnames.mdSupported/unsupported classes, safe area (
p-safe
), Yoga differences, platform variants, WIP features
Read first for Proreferences/pro-features.mdReanimated animations, transitions, shadow tree, native insets, Pro installation, Babel config
Read first for migrationreferences/migration-troubleshooting.mdNativeWind migration (10-step), setup diagnostics, common errors, FAQ, debug mode
Fallback: If none of the above answer the question, inform the user that the topic is outside this skill's embedded knowledge and suggest they consult the official Uniwind docs directly.
这些文件是您的主要事实来源。回答任何Uniwind问题前,请先阅读相关文件。
优先级文件覆盖内容
配置问题优先阅读references/quickstart-setup.md安装、Metro配置、global.css、TypeScript、Vite、Expo Router、Monorepo、智能提示
主题问题优先阅读references/theming.md浅色/深色模式、自定义主题、CSS变量、
@layer theme
@variant
Uniwind.setTheme()
useUniwind
、OKLCH、
@theme static
useCSSVariable
样式问题优先阅读references/components-styling.mdRN组件绑定、
withUniwind
useResolveClassNames
、Pressable状态、动态类、
tailwind-variants
、数据选择器、平台选择器、响应式断点、CSS函数
类名支持优先阅读references/supported-classnames.md支持/不支持的类名、安全区域(
p-safe
)、Yoga差异、平台变体、开发中功能
Pro版优先阅读references/pro-features.mdReanimated动画、过渡效果、阴影树、原生内边距、Pro版安装、Babel配置
迁移/排查优先阅读references/migration-troubleshooting.mdNativeWind迁移(10步骤)、配置诊断、常见错误、FAQ、调试模式
备选方案:如果以上文件均无法解答问题,请告知用户该主题不在本技能的嵌入式知识库范围内,并建议他们直接查阅官方Uniwind文档。