react-native-unistyles-v3
БесплатноБез исполняемых скриптовНе проверенGuide for using react-native-unistyles v3. Triggers on: "unistyles", "StyleSheet.create", "create stylesheet", "add theme", "breakpoints", "variants"…
от jpudysz★ 2 977 звёзд на GitHubОб этом скилле
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 a bundler integration: the zero-config Metro integration (withUnistylesConfig) or UnistylesPlugin for Re.Pack/Rspack/Rsbuild. Both swap react-native components and track StyleSheet dependencies at runtime, no Babel transform. The Babel plugin (react-native-unistyles/plugin) is deprecated since 3.9.0 and removed in 4.0. It replaces React Native's StyleSheet with a reactive, theme-aware, responsive system.
Prerequisites
- React Native 0.85+ with New Architecture mandatory (the only architecture since RN 0.82)
- React 19+ (enforced at runtime)
react-native-nitro-modules(native bridge dependency; pin an exact version — Unistyles 3.4.0+ needs>= 0.37.1)- iOS 15.1+, Android 7+
react-native-edge-to-edgeis not needed (optional since v3.1.0, now deprecated) — setedgeToEdgeEnabled=trueinandroid/gradle.propertiesinstead (Expo SDK 54+ enables it automatically)- Expo SDK 56+ (if using Expo; not compatible with Expo Go — requires dev client or prebuild)
- Xcode 16.4+ (iOS, required by Nitro Modules)
Workflow
- Read user's code first — understand current setup, imports, and styling approach
- Identify intent — new setup, add theming, responsive design, fix an issue, etc.
- Apply v3 patterns — use the correct API from this skill; consult reference files for details
- Verify correctness — check for critical rule violations (spreading, barrel re-exports, etc.)
Quick Reference
StyleSheet.create — 3 overloads
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
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, // web: themes as CSS variables (default: true)
// nativeBreakpointsMode: 'pixels' | 'points' // default 'pixels' = compare against rt.screen (pt/dp)
}
})
Variants
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 — use the styles returned by useVariants (always pass an object, `{}` for defaults)
const variantStyles = styles.useVariants({ size: 'large', color: 'primary' })
return <View style={variantStyles.button} />
withUnistyles — map theme/runtime to non-style props, or wrap views Unistyles can't bind to
React Native / Reanimated views that only take style need no wrapping. Use withUnistyles for props like color/trackColor, for contentContainerStyle, or for third-party views that don't expose a native ref.
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: <UniButton title="Press me" />
// Per-instance mapping: <UniButton uniProps={theme => ({ color: isOn ? theme.colors.on : theme.colors.off })} />
Critical Rules
- NEVER spread styles —
{...styles.x}breaks C++ proxy binding. ALWAYS use array syntax:[styles.x, styles.y]or[styles.x, { marginTop: 10 }] - NEVER re-export StyleSheet from barrel files — import it directly from
react-native-unistyles. With the deprecated Babel plugin, outsideroot,StyleSheet.createis only recognized via that import (orautoProcessImports), so a re-export silently breaks detection. (The Metro integration andUnistylesPluginhave no such limitation, but direct imports work everywhere.) - A bundler integration is REQUIRED — pick by bundler:
- **Metro (Expo, bare React N
Установить react-native-unistyles-v3 в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobEditWriteBash(npx *)Вложенные файлы
FAQ
Что делает скилл react-native-unistyles-v3?
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", "withUnistylesConfig", "unistyles metro", "UnistylesPlugin", "unistyles babel plugin". Covers setup (Metro integration, UnistylesPlugin for Re.Pack/Rspack/Rsbuild, the deprecated Babel plugin), theming, responsive design, variants, web features, third-party integration, and troubleshooting.
Как установить скилл react-native-unistyles-v3?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл react-native-unistyles-v3 запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic