跳到主内容
智客 ZICQ

技能库 智客分类:设计创意 react-native-unistyles-v3

React Native Unistyles V3

使用反应-内置-单式v3. 触发:"单式","StyleSheet.create","创建样式表","添加主题","断点","变量","Unityles","使用Unityles","缩写","UnitylesRuntime","风格组件","反应风格","媒体查询","动态风格","被扫描的主题","适应主题","单式设置","单式配置". 封面设置,主题设计,响应设计,变体,网络功能,第三方融合,以及故障排除.

417 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

使用反应-内置-单式v3. 触发:"单式","StyleSheet.create","创建样式表","添加主题","断点","变量","Unityles","使用Unityles","缩写","UnitylesRuntime","风格组件","反应风格","媒体查询","动态风格","被扫描的主题","适应主题","单式设置","单式配置". 封面设置,主题设计,响应设计,变体,网络功能,第三方融合,以及故障排除.

何时用

官方 description 未单独写出 Use when。按规范,代理会在用户任务与这段 description 的关键词匹配时激活本技能。

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:React Native Unistyles v3 Skill、Prerequisites、Workflow、Quick Reference、StyleSheet.create — 3 overloads、StyleSheet.configure — one-time setup。 其中含规范建议的小节:分步指令。

文件分析

文件分析:除 SKILL.md 外,正文引用了 references/setup-guide.md、references/api-reference.md、references/styling-patterns.md、references/third-party-integration.md、references/common-issues.md,属于带资源的技能包,这些文件按需再读。

官方 description(原文)

Guide for using react-native-unistyles v3. Triggers on: "unistyles", "StyleSheet.create", "create stylesheet", "add theme", "breakpoints", "variants", "withUnistyles", "useUnistyles", "ScopedTheme", "UnistylesRuntime", "style component", "responsive styles", "media queries", "dynamic styles", "scoped theme", "adaptive theme", "unistyles setup", "unistyles config". Covers setup, theming, responsive design, variants, web features, third-party integration, and troubleshooting.

React Native Unistyles v3 SkillPrerequisitesWorkflowQuick ReferenceStyleSheet.create — 3 overloadsStyleSheet.configure — one-time setupVariantswithUnistyles — wrap third-party components (not React Native or Reanimated components)Critical RulesDecision TreesChoosing a styling approachThird-party component integration

· allowed-tools:Read, Grep, Glob, Edit, Write, Bash(npx *)

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
react-native-unistyles-v3
description
Guide for using react-native-unistyles v3. Triggers on: "unistyles", "StyleSheet.create", "create stylesheet", "add theme", "breakpoints", "variants", "withUnistyles", "useUnistyles", "ScopedTheme", "UnistylesRuntime", "style component", "responsive styles", "media queries", "dynamic styles", "scoped theme", "adaptive theme", "unistyles setup", "unistyles config". Covers setup, theming, responsive design, variants, web features, third-party integration, and troubleshooting.
allowed-tools
Read, Grep, Glob, Edit, Write, Bash(npx *)实验字段,支持情况取决于客户端;字段声明本身不会授予工具权限。
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。
指令中引用的文件 · 5
  • references/setup-guide.md
  • references/api-reference.md
  • references/styling-patterns.md
  • references/third-party-integration.md
  • references/common-issues.md

以下路径提取自原文;文件是否齐全请以来源仓库中的完整目录为准。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

该技能引用了附属文件,请从来源获取完整目录;仅复制 SKILL.md 可能缺少依赖。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「react-native-unistyles-v3」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-29f595883d0a05f8-%E5%8F%8D%E5%BA%94%E5%8E%9F%E7%94%9F%E4%B8%80%E5%BC%8FV3.html
请存为 .cursor/skills/react-native-unistyles-v3/SKILL.md 或 .claude/skills/react-native-unistyles-v3/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。
该技能还带 scripts/、references/、assets/ 等文件,请从 https://github.com/jpudysz/react-native-unistyles 取完整目录,不要只建一个 SKILL.md。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/jpudysz/react-native-unistyles' --list

npx skills add 'https://github.com/jpudysz/react-native-unistyles' --skill 'react-native-unistyles-v3'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: react-native-unistyles-v3 description: > Guide for using react-native-unistyles v3. Triggers on: "unistyles", "StyleSheet.create", "create stylesheet", "add theme", "breakpoints", "variants", "withUnistyles", "useUnistyles", "ScopedTheme", "UnistylesRuntime", "style component", "responsive styles", "media queries", "dynamic styles", "scoped theme", "adaptive theme", "unistyles setup", "unistyles config". Covers setup, theming, responsive design, variants, web features, third-party integration, and troubleshooting. disable-model-invocation: false user-invocable: true allowed-tools: Read, Grep, Glob, Edit, Write, Bash(npx *) --- # React Native Unistyles v3 Skill You are assisting with React Native Unistyles v3 styling. v3 is a zero-re-render styling library with a C++ core (Nitro Modules) and Babel plugin that processes StyleSheets at build time. It replaces React Native's `StyleSheet` with a reactive, theme-aware, responsive system. ## Prerequisites - React Native 0.78+ with **New Architecture mandatory** (default from RN 0.83+) - React 19+ (enforced at runtime) - `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) ## Workflow 1. **Read user's code first** — understand current setup, imports, and styling approach 2. **Identify intent** — new setup, add theming, responsive design, fix an issue, etc. 3. **Apply v3 patterns** — use the correct API from this skill; consult reference files for details 4. **Verify correctness** — check for critical rule violations (spreading, barrel re-exports, etc.) ## Quick Reference ### StyleSheet.create — 3 overloads ```tsx import { StyleSheet } from 'react-native-unistyles' // 1. Static object compatible with React Native StyleSheet.create const styles = StyleSheet.create({ container: { flex: 1, padding: 16 } }) // 2. Theme function (reactive to theme changes, zero re-renders) const styles = StyleSheet.create(theme => ({ container: { backgroundColor: theme.colors.background } })) // 3. Theme + miniRuntime function (reactive to theme AND device state) const styles = StyleSheet.create((theme, rt) => ({ container: { backgroundColor: theme.colors.background, paddingTop: rt.insets.top, width: rt.screen.width > 768 ? 500 : rt.screen.width - 32 } })) ``` ### StyleSheet.configure — one-time setup ```tsx StyleSheet.configure({ themes: { light: lightTheme, dark: darkTheme }, breakpoints: { xs: 0, sm: 576, md: 768, lg: 992, xl: 1200 }, settings: { initialTheme: 'light', // or: () => storage.getString('theme') ?? 'light' // adaptiveThemes: true, // auto-switch light/dark based on OS (mutually exclusive with initialTheme) // CSSVars: true, // use CSS custom properties on web // nativeBreakpointsMode: 'pixels' | 'points' } }) ``` ### Variants ```tsx const styles = StyleSheet.create(theme => ({ button: { variants: { size: { small: { padding: 4 }, medium: { padding: 8 }, large: { padding: 16 }, }, color: { primary: { backgroundColor: theme.colors.primary }, secondary: { backgroundColor: theme.colors.secondary }, } }, compoundVariants: [ { size: 'large', color: 'primary', styles: { borderWidth: 2 } } ], } })) // In component — call useVariants BEFORE accessing styles styles.useVariants({ size: 'large', color: 'primary' }) return ``` ### withUnistyles — wrap third-party components (not React Native or Reanimated components) ```tsx import { withUnistyles } from 'react-native-unistyles' import { Button } from 'some-library' const UniButton = withUnistyles(Button, (theme, rt) => ({ color: theme.colors.primary, size: rt.screen.width > 400 ? 'large' : 'small' })) // Usage: ``` ## Critical Rules 1. **NEVER spread styles** — `{...styles.x}` breaks C++ proxy binding. ALWAYS use array syntax: `[styles.x, styles.y]` or `[styles.x, { marginTop: 10 }]` 2. **NEVER re-export StyleSheet from barrel files** — the Babel plugin detects `StyleSheet.create` by import source. Re-exporting breaks detection. 3. **Babel plugin is REQUIRED** — add `['react-native-unistyles/plugin', { root: 'src' }]` to babel.config.js. 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`). Replace all `import { StyleSheet } from 'react-native'`. 5. **`styles.useVariants()` must be called before accessing variant-dependent styles** — treat it like a React hook (top of component). 6. **Prefer `StyleSheet.create(theme => ...)` over `useUnistyles()`** — theme functions cause zero re-renders; `useUnistyles()` re-renders on every theme/runtime change. 7. **`StyleSheet.configure()` must be called before any `StyleSheet.create()`** — typically in your app entry point, before any component renders. ## Decision Trees ### Choosing a styling approach ``` Need theme/runtime in styles? ├─ YES → StyleSheet.create((theme, rt) => ...) [zero re-renders] └─ NO → StyleSheet.create({ ... }) [static styles] Need theme values as non-style props? ├─ YES → withUnistyles(Component, (theme, rt) => ({ propName: theme.value })) └─ NO → Pass Unistyles styles via style prop directly Need theme/runtime in component logic (not just styles)? ├─ YES → useUnistyles() hook [causes re-renders] └─ NO → Use StyleSheet.create with theme function ``` ### Third-party component integration ``` Does the component accept a `style` prop? ├─ YES → Pass Unistyles styles directly (Babel auto-processes standard RN views) │ If it's a custom native view → add to autoProcessPaths in Babel config ├─ NO → Does it accept theme-derived props (color, size, etc.)? │ ├─ YES → withUnistyles(Component, (theme, rt) => ({ prop: theme.value })) │ └─ NO → useUnistyles() as fallback └─ Component from node_modules not processed? → Add its path to autoProcessPaths or autoProcessImports in Babel plugin config ``` ## Reference Files - **Setup, installation, Babel plugin, TypeScript, testing, Expo Router**: read [references/setup-guide.md](references/setup-guide.md) - **Complete API for every export**: read [references/api-reference.md](references/api-reference.md) - **Code patterns: themes, variants, breakpoints, web, SSR, Reanimated**: read [references/styling-patterns.md](references/styling-patterns.md) - **withUnistyles, autoProcessPaths, React Compiler, Reanimated, FlatList**: read [references/third-party-integration.md](references/third-party-integration.md) - **Troubleshooting from 150+ GitHub issues with solutions**: read [references/common-issues.md](references/common-issues.md)

相关技能

设计创意

Automation Workflows

设计和实施自动化工作流程,以节省时间和规模化操作作为独家. 用于识别重复任务实现自动化,构建跨工具的工作流程,设置触发器和行动,或优化现有自动化. 包括自动化机会识别,工作流程设计,工具选择(Zapier,Make,n8n),测试,和维护. 触发"自动","自动","工作流程自动…

设计创意

Ui Ux Pro Max

UI/UX设计智能及建筑抛光接口实施指导. 当用户要求UI设计,UX流量,信息架构,视觉风格方向,设计系统/托盘,组件规格,副本/显微镜,可访问性,或生成/critique/refine前端UI(HTML/CSS/JS,React,Next.js,Vue,Svelte,Tailw…

设计创意

Frontend Design

创建美丽现代UI的专家前端设计指南. 在构建起落架页面,仪表板,或任何用户界面时使用.

设计创意

N8n Workflow Automation

设计和输出 n8n 工作流程 JSON 有强力触发器, idempotency, 错误处理, 记录, 重试, 以及 人入"一站"审查队列. 当您需要可审计的自动化时使用.