Token导航 LogoToken导航

Agent Skill · 前端设计

unistyles-v2-to-v3-migration(unistyles v2 到 v3 的迁移)

unistyles-v2-to-v3-migration 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

unistyles-v2-to-v3-migration 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为权限未标注;许可证信息还不明确,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 4,145。

总安装 979周安装 40GitHub Stars 2,918下载 314核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:unistyles-v2-to-v3-migration(unistyles v2 到 v3 的迁移)
来源仓库:https://github.com/jpudysz/react-native-unistyles
仓库路径:skills/unistyles-v2-to-v3-migration
安装命令:
npx skills add https://github.com/jpudysz/react-native-unistyles --skill unistyles-v2-to-v3-migration
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/jpudysz/react-native-unistyles --skill unistyles-v2-to-v3-migration

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

该技能用于协助将 unistyles v2 项目迁移至 v3 版本。适用于需要升级 React Native 样式管理库的开发者,特别是在 Codex、Claude、Cursor 和 Gemini CLI 环境中进行代码重构时。通过分析现有代码结构,生成迁移指南和适配代码,帮助平滑过渡到新版 API。

安装前请确认项目依赖和权限范围,避免影响生产环境代码。unistyles-v2-to-v3-migration 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/unistyles-v2-to-v3-migration

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/jpudysz/react-native-unistyles --skill unistyl…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    权限没有明确标注,第一次使用时只给一个无关紧要的任务,观察它到底读了哪些文件和网络。

常见问题

6 条

unistyles-v2-to-v3-migration 怎么安装?

在终端执行 npx skills add https://github.com/jpudysz/react-native-unistyles --skill unistyles-v2-to-v…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

unistyles-v2-to-v3-migration 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

unistyles-v2-to-v3-migration 需要什么权限?

权限级别没有明确标注。第一次使用时建议只给无关紧要的任务,观察它实际读写了哪些内容。

unistyles-v2-to-v3-migration 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

unistyles-v2-to-v3-migration 用的人多吗?

公开数据是累计安装 979 次,近一周安装 40 次,下载 314 次,GitHub 2,918 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

unistyles-v2-to-v3-migration 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。
  • 来源仓库有 2,918 星,维护活跃度相对可查。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
unistyles-v2-to-v3-migration

unistyles v2 到 v3 的迁移 · 本页

9792,918权限未标注未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Unistyles v2 to v3 Migration Skill

You are migrating a React Native codebase from react-native-unistyles v2 to v3. Follow this workflow precisely. v3 is a complete rewrite with C++ core (Nitro Modules), no re-renders, and a Babel plugin that processes StyleSheets at build time.

Prerequisites

  • React Native 0.78.0+ with New Architecture mandatory (enabled by default from RN 0.83+)
  • React 19+ (enforced at runtime by Unistyles)
  • react-native-nitro-modules (native bridge dependency)
  • react-native-edge-to-edge (required for Android edge-to-edge insets)
  • Expo SDK 53+ (if using Expo; not compatible with Expo Go — requires dev client or prebuild)
  • Xcode 16+ (iOS)

Migration Workflow

Follow these steps IN ORDER. Each step must be completed before moving to the next.

Step 1: Install v3 and configure Babel plugin

Install react-native-unistyles@3 and add the Babel plugin:

// babel.config.js
module.exports = {
  plugins: [
    ['react-native-unistyles/plugin', { root: 'src' }]  // your app source root
  ]
}

The root option is REQUIRED. It tells the plugin which directory contains your app code. Files outside this directory (except node_modules paths you explicitly configure) won't be processed.

If using React Compiler, the Unistyles plugin MUST come BEFORE React Compiler in the plugins array.

Step 2: Replace UnistylesRegistry with StyleSheet.configure

- import { UnistylesRegistry } from 'react-native-unistyles'
+ import { StyleSheet } from 'react-native-unistyles'

- UnistylesRegistry
-   .addThemes({ light: lightTheme, dark: darkTheme })
-   .addBreakpoints({ sm: 0, md: 768, lg: 1200 })
-   .addConfig({
-     adaptiveThemes: true,
-     initialTheme: 'dark',
-     plugins: [myPlugin],
-     experimentalCSSMediaQueries: true,
-     windowResizeDebounceTimeMs: 100,
-     disableAnimatedInsets: true
-   })
+ StyleSheet.configure({
+   themes: { light: lightTheme, dark: darkTheme },
+   breakpoints: { sm: 0, md: 768, lg: 1200 },
+   settings: {
+     adaptiveThemes: true,
+     initialTheme: 'dark'
+   }
+ })

Removed settings: plugins, experimentalCSSMediaQueries (now always on), windowResizeDebounceTimeMs (no debounce), disableAnimatedInsets (insets no longer re-render).

Step 3: Replace all StyleSheet imports and createStyleSheet

Unistyles StyleSheet is a full polyfill of React Native's StyleSheet — it includes hairlineWidth, compose, flatten, absoluteFill, and absoluteFillObject. You should replace all import {StyleSheet} from 'react-native' with import {StyleSheet} from 'react-native-unistyles' so you have a single import.

- import { StyleSheet } from 'react-native'
- import { createStyleSheet } from 'react-native-unistyles'
+ import { StyleSheet } from 'react-native-unistyles'

- const stylesheet = createStyleSheet(theme => ({
+ const styles = StyleSheet.create(theme => ({
    container: {
      backgroundColor: theme.colors.background
    }
  }))

Step 4: Remove all useStyles hooks

- import { useStyles } from 'react-native-unistyles'

  const MyComponent = () => {
-   const { styles, theme } = useStyles(stylesheet)
    return <View style={styles.container} />
  }

Styles created with StyleSheet.create are used directly - no hook needed. The Babel plugin handles reactivity at build time.

Step 5: Replace useInitialTheme with settings.initialTheme

- import { useInitialTheme } from 'react-native-unistyles'
-
- const App = () => {
-   useInitialTheme(storage.getString('preferredTheme') ?? 'light')
-   return <Stack />
- }

+ // In your configure call:
+ StyleSheet.configure({
+   settings: {
+     initialTheme: () => storage.getString('preferredTheme') ?? 'light'
+   }
+ })

initialTheme accepts a string or a synchronous function.

Step 6: Replace useStyles() for theme access

For components that used useStyles() (without a stylesheet) just to get theme/runtime:

Option A - withUnistyles (preferred for passing theme-derived props):

import { withUnistyles } from 'react-native-unistyles'

const UniButton = withUnistyles(Button, (theme, rt) => ({
  color: theme.colors.primary,
  size: rt.screen.width > 400 ? 'large' : 'small'
}))

// Usage: <UniButton />

Option B - useUnistyles hook (quick migration path):

import { useUnistyles } from 'react-native-unistyles'

const MyComponent = () => {
  const { theme, rt } = useUnistyles()
  return <Text style={{ color: theme.colors.primary }}>{rt.screen.width}</Text>
}

WARNING: useUnistyles causes re-renders when theme/runtime changes. Prefer withUnistyles or StyleSheet.create(theme =>...) for performance.

Step 7: Update variant selection

- const { styles } = useStyles(stylesheet, { size: 'large', color: 'primary' })
+ styles.useVariants({ size: 'large', color: 'primary' })

Call styles.useVariants() at the top of your component (like a hook). It must be called before accessing styles that use variants.

Step 8: Fix style spreading (CRITICAL)

v3 styles are C++ proxy objects. Spreading breaks the binding.

- <View style={{ ...styles.container, ...styles.extra }} />
+ <View style={[styles.container, styles.extra]} />

- <View style={{ ...styles.container, marginTop: 10 }} />
+ <View style={[styles.container, { marginTop: 10 }]} />

NEVER use {...styles.x}. ALWAYS use [styles.x, styles.y] array syntax.

Step 9: Remove plugins (use static functions in theme instead)

The plugin system is removed. Replace plugins with static functions in your theme or StyleSheet:

- // Plugin approach (v2)
- const fontPlugin: UnistylesPlugin = {
-   name: 'fontPlugin',
-   onParsedStyle: (_key, styles) => {
-     if ('fontWeight' in styles) {
-       styles.fontFamily = styles.fontWeight === 'bold' ? 'Roboto-Bold' : 'Roboto-Regular'
-     }
-     return styles
-   }
- }

+ // v3: Use a helper function in your theme or directly
+ const styles = StyleSheet.create(theme => ({
+   text: {
+     fontFamily: theme.utils.getFontFamily('bold')
+   }
+ }))

Step 10: Remove UnistylesProvider

UnistylesProvider no longer exists. Simply remove it from your component tree.

Step 11: Update UnistylesRuntime usage

Renamed/changed methods:

  • UnistylesRuntime.setImmersiveMode(bool) replaces separate status bar/nav bar hide
  • UnistylesRuntime.setRootViewBackgroundColor(color) - no more alpha parameter
  • StyleSheet.hairlineWidth instead of UnistylesRuntime.hairlineWidth

Removed methods:

  • addPlugin(plugin), removePlugin(plugin), enabledPlugins
  • statusBar.setColor(color), navigationBar.setColor(color)

New properties on UnistylesRuntime:

  • statusBar object with setHidden(hidden, animation) and setStyle(style)
  • navigationBar object with setHidden(hidden)
  • insets.ime for keyboard inset

Step 12: Update TypeScript declarations

- type AppThemes = { light: typeof lightTheme, dark: typeof darkTheme }
+ type AppThemes = typeof themes  // where themes = { light: lightTheme, dark: darkTheme }

  declare module 'react-native-unistyles' {
    export interface UnistylesThemes extends AppThemes {}
+   export interface UnistylesBreakpoints extends typeof breakpoints {}
  }

Step 13: Update keyboard/IME handling

- import { useAnimatedKeyboard } from 'react-native-reanimated'
- const keyboard = useAnimatedKeyboard()

+ // Use ime inset in StyleSheet
+ const styles = StyleSheet.create((theme, rt) => ({
+   container: {
+     paddingBottom: rt.insets.ime
+   }
+ }))

Step 14: Set up testing mocks

// jest.setup.js
require('react-native-unistyles/mocks')
require('./unistyles.config') // your StyleSheet.configure call

The Babel plugin auto-disables in test environments (NODE_ENV=test).

Expo Router Integration

If the project uses Expo Router, extra steps are needed because Expo Router resolves routes before Unistyles can initialize.

1. Change the main entry point in package.json:

{ "main": "index.ts" }

2. Create index.ts that imports Unistyles config before the router:

import 'expo-router/entry'
import './unistyles' // your StyleSheet.configure() file

3. For static rendering (Expo SDK 52+): import the Unistyles config in +html.tsx as well:

import '../unistyles' // ensures Unistyles initializes for each static page

import { ScrollViewStyleReset } from 'expo-router/html';
import { type PropsWithChildren } from 'react';

// This file is web-only and used to configure the root HTML for every
// web page during static rendering.
// The contents of this function only run in Node.js environments and
// do not have access to the DOM or browser APIs.
export default function Root({ children }: PropsWithChildren) {
  return (
    <html lang="en">
      <head>
        <meta charSet="utf-8" />
        <meta httpEquiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />

        {/*
          Disable body scrolling on web. This makes ScrollView components work closer to how they do on native.
          However, body scrolling is often nice to have for mobile web. If you want to enable it, remove this line.
        */}
        <ScrollViewStyleReset />

        {/* Add any additional <head> elements that you want globally available on web... */}
      </head>
      <body>{children}</body>
    </html>
  );
}

See https://www.unistyl.es/v3/guides/expo-router for full details.

Quick Reference: v2 API to v3

v2v3
createStyleSheetStyleSheet.create
useStyles(stylesheet)Use styles directly (no hook)
useStyles() for themeuseUnistyles() or withUnistyles
useStyles(ss, variants)styles.useVariants(variants)
useInitialTheme(name)settings.initialTheme in configure
UnistylesRegistry.addThemes()StyleSheet.configure({themes})
UnistylesRegistry.addBreakpoints()StyleSheet.configure({breakpoints})
UnistylesRegistry.addConfig()StyleSheet.configure({settings})
UnistylesProviderRemoved (not needed)
UnistylesPluginRemoved (use theme functions)
{...styles.x,...styles.y}[styles.x, styles.y]
UnistylesRuntime.hairlineWidthStyleSheet.hairlineWidth
statusBar.setColor()Removed
navigationBar.setColor()Removed
import {StyleSheet} from 'react-native'import {StyleSheet} from 'react-native-unistyles' (full polyfill)

Decision Tree: Third-Party Components

When a third-party component needs theme values or Unistyles styles:

  1. Does it accept a style prop? -> Pass Unistyles styles directly (Babel plugin handles it for standard RN components)
  2. Does it need theme-derived non-style props (e.g. color)? -> Wrap with withUnistyles
  3. Is it from a library with custom native views? -> Configure autoProcessPaths in Babel plugin
  4. None of the above work? -> Use useUnistyles() hook as fallback

Critical Rules

  1. New Architecture is mandatory - enable it explicitly (default from RN 0.83+)
  2. NEVER spread styles - always use array syntax [styles.a, styles.b]
  3. Babel plugin is REQUIRED - without it, styles won't be reactive
  4. Import StyleSheet from react-native-unistyles only - it polyfills all RN StyleSheet APIs (hairlineWidth, compose, flatten, absoluteFill, etc.), so remove any import {StyleSheet} from 'react-native'
  5. Never re-export StyleSheet from barrel files - the Babel plugin won't detect it
  6. styles.useVariants() must be called before accessing styles in the component render
  7. React 19+ is required - v3 uses the new React architecture

Reference Files

平台分布

Codex

33.22%
按下载量换算104

Claude

31.68%
按下载量换算99

Cursor

18.64%
按下载量换算59

Gemini CLI

8.77%
按下载量换算28

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

权限未标注

当前来源未能明确判断权限范围,默认进入异常复核队列。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills