Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build performant React Native and Expo apps with best practices for lists, animations, and navigation
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/ui-styling.md
1---2title: Modern React Native Styling Patterns3impact: MEDIUM4impactDescription: consistent design, smoother borders, cleaner layouts5tags: styling, css, layout, shadows, gradients6---78## Modern React Native Styling Patterns910Follow these styling patterns for cleaner, more consistent React Native code.1112**Always use `borderCurve: 'continuous'` with `borderRadius`:**1314```tsx15// Incorrect16{ borderRadius: 12 }1718// Correct – smoother iOS-style corners19{ borderRadius: 12, borderCurve: 'continuous' }20```2122**Use `gap` instead of margin for spacing between elements:**2324```tsx25// Incorrect – margin on children26<View>27<Text style={{ marginBottom: 8 }}>Title</Text>28<Text style={{ marginBottom: 8 }}>Subtitle</Text>29</View>3031// Correct – gap on parent32<View style={{ gap: 8 }}>33<Text>Title</Text>34<Text>Subtitle</Text>35</View>36```3738**Use `padding` for space within, `gap` for space between:**3940```tsx41<View style={{ padding: 16, gap: 12 }}>42<Text>First</Text>43<Text>Second</Text>44</View>45```4647**Use `experimental_backgroundImage` for linear gradients:**4849```tsx50// Incorrect – third-party gradient library51<LinearGradient colors={['#000', '#fff']} />5253// Correct – native CSS gradient syntax54<View55style={{56experimental_backgroundImage: 'linear-gradient(to bottom, #000, #fff)',57}}58/>59```6061**Use CSS `boxShadow` string syntax for shadows:**6263```tsx64// Incorrect – legacy shadow objects or elevation65{ shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.1 }66{ elevation: 4 }6768// Correct – CSS box-shadow syntax69{ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)' }70```7172**Avoid multiple font sizes – use weight and color for emphasis:**7374```tsx75// Incorrect – varying font sizes for hierarchy76<Text style={{ fontSize: 18 }}>Title</Text>77<Text style={{ fontSize: 14 }}>Subtitle</Text>78<Text style={{ fontSize: 12 }}>Caption</Text>7980// Correct – consistent size, vary weight and color81<Text style={{ fontWeight: '600' }}>Title</Text>82<Text style={{ color: '#666' }}>Subtitle</Text>83<Text style={{ color: '#999' }}>Caption</Text>84```8586Limiting font sizes creates visual consistency. Use `fontWeight` (bold/semibold)87and grayscale colors for hierarchy instead.88