Habilidades rn-styling
🎨

rn-styling

Seguro

应用 React Native 样式模式

React Native 样式与 Web CSS 不同。此技能提供经过验证的 NativeWind、BrandColors、平台特定样式和响应式布局模式,用于构建一致的跨平台移动 UI。

Suporta: Claude Codex Code(CC)
📊 70 Adequado
1

Baixar o ZIP da skill

2

Upload no Claude

Vá em Configurações → Capacidades → Skills → Upload skill

3

Ative e comece a usar

Testar

A utilizar "rn-styling". 使用品牌颜色和 NativeWind 为卡片组件设置样式

Resultado esperado:

```typescript
import { BrandColors } from '@/constants/BrandColors';

// Hybrid approach: NativeWind for layout, BrandColors for semantic colors
<View className="flex-1 p-4 rounded-lg" style={{ backgroundColor: BrandColors.cardBackground }}>
<Text className="text-lg font-semibold" style={{ color: BrandColors.textPrimary }}>
Card Title
</Text>
</View>
```

A utilizar "rn-styling". 处理平台特定的阴影

Resultado esperado:

```typescript
import { Platform, StyleSheet } from 'react-native';

const styles = StyleSheet.create({
shadow: Platform.select({
ios: {
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.1,
shadowRadius: 4,
},
android: {
elevation: 4,
},
}),
});
```

A utilizar "rn-styling". 使用断点创建响应式布局

Resultado esperado:

```typescript
import { useWindowDimensions } from 'react-native';

function ResponsiveLayout() {
const { width } = useWindowDimensions();
const isTablet = width >= 768;

return (
<View className={`p-2 sm:p-4 md:p-6 ${isTablet ? 'flex-row' : 'flex-col'}`} />
);
}
```

Auditoria de Segurança

Seguro
v5 • 1/21/2026

All 42 static findings are false positives. The scanner misidentified TypeScript code examples (backticks for template literals), React Native platform APIs (Platform.OS, Platform.select), and YAML frontmatter as security issues. This is a legitimate documentation skill with no malicious code or security risks.

2
Arquivos analisados
893
Linhas analisadas
0
achados
5
Total de auditorias
Nenhum problema de segurança encontrado
Auditado por: claude Ver Histórico de Auditoria →

Pontuação de qualidade

38
Arquitetura
100
Manutenibilidade
87
Conteúdo
22
Comunidade
100
Segurança
91
Conformidade com especificações

O Que Você Pode Construir

移动应用开发者创建新组件

使用 NativeWind 类和语义化 BrandColors 构建新的 React Native 界面时应用一致的样式模式。

跨平台团队标准化 UI

使用平台特定模式和响应式断点在 iOS 和 Android 团队中建立一致的样式约定。

React Native 开发者添加深色模式

在现有 React Native 应用程序中实现主题感知颜色和 BrandColorsDark 变体,以支持浅色和深色模式。

Tente Estes Prompts

基础样式问题
如何使用 NativeWind 为 React Native 组件设置样式?向我展示如何应用内边距、背景颜色和圆角。
颜色和主题问题
帮我为 React Native 应用设置 BrandColors。我需要主色、次要色、背景色和文本的语义化颜色,并支持深色模式。
平台差异问题
我的阴影在 iOS 上有效但在 Android 上无效。如何在 React Native 中处理平台特定样式?向我展示 Platform.select 和 NativeWind 两种方法。
复杂布局问题
我需要创建一个适应平板和手机屏幕的响应式卡片组件。它应该处理安全区域、键盘避让并支持动画过渡。向我展示完整的模式。

Melhores Práticas

  • 使用 BrandColors 处理语义化颜色(主色、背景色、文本色),使用 NativeWind 处理布局工具类(内边距、外边距、flex)
  • 谨慎应用 NativeWind 类的顺序,因为 React Native 不会层叠样式 - 对于冲突的属性,最后一个类会生效
  • 为动画组件组合样式数组而不是展开 StyleSheet 对象,以避免在每次渲染时创建新对象

Evitar

  • 在组件中直接硬编码十六进制颜色而不使用 BrandColors - 这会破坏主题一致性
  • 使用 NativeWind 颜色类如 bg-blue-500 作为品牌颜色 - 这些应该来自 BrandColors
  • 展开样式对象如 style={{ ...styles.card, opacity: fadeAnim }} - 这会在每次渲染时创建新对象,导致性能问题

Perguntas Frequentes

什么是 NativeWind,它与 Web 版 Tailwind 有何不同?
NativeWind 是 Tailwind CSS 的 React Native 移植版。它为移动端带来了工具类,但与 Web 版并非完全一致。一些 Web Tailwind 工具类不受支持,v2 断点与 Web 版不同(sm: 640px, md: 768px, lg: 1024px, xl: 1280px)。
何时应该使用 StyleSheet.create 而不是 NativeWind 类?
对于复杂的可复用样式、性能关键组件和 iOS 阴影,使用 StyleSheet。对于简单的布局工具类、一次性样式和条件类,使用 NativeWind。混合方法效果最佳。
如何使用 BrandColors 处理浅色和深色模式?
创建 BrandColors 和 BrandColorsDark 常量文件。使用 react-native 的 useColorScheme 钩子检测当前主题并返回相应的颜色对象。通过 style 属性将这些颜色传递给组件。
为什么我的 NativeWind 类没有生效?
并非所有 Web Tailwind 工具类都适用于 NativeWind。查看 NativeWind v2 文档以了解支持的工具类。还要确保在 React Native 组件上使用 className 属性(而不是 style)。
如何在有刘海的设备上处理安全区域?
使用 react-native-safe-area-context 中的 SafeAreaView 及其 edges 属性,或使用 useSafeAreaInsets 钩子进行手动控制。如果配置了 NativeWind,它可能有安全区域工具类。
是什么导致 React Native 中挂载时的样式闪烁?
样式闪烁通常发生在初始渲染后应用样式时。使用 Animated API 配合 useRef 创建 Animated.Value,以实现流畅过渡,而不是立即更改样式。

Detalhes do Desenvolvedor

Estrutura de arquivos

📄 SKILL.md