Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Official Expo team skill for building native UI in Expo apps, fine-tuned for Opus models and usable with Claude Code or Cursor.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: building-native-ui3description: Complete guide for building beautiful apps with Expo Router. Covers fundamentals, styling, components, navigation, animations, patterns, and native tabs.4version: 1.0.15license: MIT6---78# Expo UI Guidelines910## References1112Consult these resources as needed:1314```15references/16animations.md Reanimated: entering, exiting, layout, scroll-driven, gestures17controls.md Native iOS: Switch, Slider, SegmentedControl, DateTimePicker, Picker18form-sheet.md Form sheets in expo-router: configuration, footers and background interaction.19gradients.md CSS gradients via experimental_backgroundImage (New Arch only)20icons.md SF Symbols via expo-image (sf: source), names, animations, weights21media.md Camera, audio, video, and file saving22route-structure.md Route conventions, dynamic routes, groups, folder organization23search.md Search bar with headers, useSearch hook, filtering patterns24storage.md SQLite, AsyncStorage, SecureStore25tabs.md NativeTabs, migration from JS tabs, iOS 26 features26toolbar-and-headers.md Stack headers and toolbar buttons, menus, search (iOS only)27visual-effects.md Blur (expo-blur) and liquid glass (expo-glass-effect)28webgpu-three.md 3D graphics, games, GPU visualizations with WebGPU and Three.js29zoom-transitions.md Apple Zoom: fluid zoom transitions with Link.AppleZoom (iOS 18+)30```3132## Running the App3334**CRITICAL: Always try Expo Go first before creating custom builds.**3536Most Expo apps work in Expo Go without any custom native code. Before running `npx expo run:ios` or `npx expo run:android`:37381. **Start with Expo Go**: Run `npx expo start` and scan the QR code with Expo Go392. **Check if features work**: Test your app thoroughly in Expo Go403. **Only create custom builds when required** - see below4142### When Custom Builds Are Required4344You need `npx expo run:ios/android` or `eas build` ONLY when using:4546- **Local Expo modules** (custom native code in `modules/`)47- **Apple targets** (widgets, app clips, extensions via `@bacons/apple-targets`)48- **Third-party native modules** not included in Expo Go49- **Custom native configuration** that can't be expressed in `app.json`5051### When Expo Go Works5253Expo Go supports a huge range of features out of the box:5455- All `expo-*` packages (camera, location, notifications, etc.)56- Expo Router navigation57- Most UI libraries (reanimated, gesture handler, etc.)58- Push notifications, deep links, and more5960**If you're unsure, try Expo Go first.** Creating custom builds adds complexity, slower iteration, and requires Xcode/Android Studio setup.6162## Code Style6364- Be cautious of unterminated strings. Ensure nested backticks are escaped; never forget to escape quotes correctly.65- Always use import statements at the top of the file.66- Always use kebab-case for file names, e.g. `comment-card.tsx`67- Always remove old route files when moving or restructuring navigation68- Never use special characters in file names69- Configure tsconfig.json with path aliases, and prefer aliases over relative imports for refactors.7071## Routes7273See `./references/route-structure.md` for detailed route conventions.7475- Routes belong in the `app` directory.76- Never co-locate components, types, or utilities in the app directory. This is an anti-pattern.77- Ensure the app always has a route that matches "/", it may be inside a group route.7879## Library Preferences8081- Never use modules removed from React Native such as Picker, WebView, SafeAreaView, or AsyncStorage82- Never use legacy expo-permissions83- `expo-audio` not `expo-av`84- `expo-video` not `expo-av`85- `expo-image` with `source="sf:name"` for SF Symbols, not `expo-symbols` or `@expo/vector-icons`86- `react-native-safe-area-context` not react-native SafeAreaView87- `process.env.EXPO_OS` not `Platform.OS`88- `React.use` not `React.useContext`89- `expo-image` Image component instead of intrinsic element `img`90- `expo-glass-effect` for liquid glass backdrops9192## Responsiveness9394- Always wrap root component in a scroll view for responsiveness95- Use `<ScrollView contentInsetAdjustmentBehavior="automatic" />` instead of `<SafeAreaView>` for smarter safe area insets96- `contentInsetAdjustmentBehavior="automatic"` should be applied to FlatList and SectionList as well97- Use flexbox instead of Dimensions API98- ALWAYS prefer `useWindowDimensions` over `Dimensions.get()` to measure screen size99100## Behavior101102- Use expo-haptics conditionally on iOS to make more delightful experiences103- Use views with built-in haptics like `<Switch />` from React Native and `@react-native-community/datetimepicker`104- When a route belongs to a Stack, its first child should almost always be a ScrollView with `contentInsetAdjustmentBehavior="automatic"` set105- When adding a `ScrollView` to the page it should almost always be the first component inside the route component106- Prefer `headerSearchBarOptions` in Stack.Screen options to add a search bar107- Use the `<Text selectable />` prop on text containing data that could be copied108- Consider formatting large numbers like 1.4M or 38k109- Never use intrinsic elements like 'img' or 'div' unless in a webview or Expo DOM component110111# Styling112113Follow Apple Human Interface Guidelines.114115## General Styling Rules116117- Prefer flex gap over margin and padding styles118- Prefer padding over margin where possible119- Always account for safe area, either with stack headers, tabs, or ScrollView/FlatList `contentInsetAdjustmentBehavior="automatic"`120- Ensure both top and bottom safe area insets are accounted for121- Inline styles not StyleSheet.create unless reusing styles is faster122- Add entering and exiting animations for state changes123- Use `{ borderCurve: 'continuous' }` for rounded corners unless creating a capsule shape124- ALWAYS use a navigation stack title instead of a custom text element on the page125- When padding a ScrollView, use `contentContainerStyle` padding and gap instead of padding on the ScrollView itself (reduces clipping)126- CSS and Tailwind are not supported - use inline styles127128## Text Styling129130- Add the `selectable` prop to every `<Text/>` element displaying important data or error messages131- Counters should use `{ fontVariant: 'tabular-nums' }` for alignment132133## Shadows134135Use CSS `boxShadow` style prop. NEVER use legacy React Native shadow or elevation styles.136137```tsx138<View style={{ boxShadow: "0 1px 2px rgba(0, 0, 0, 0.05)" }} />139```140141'inset' shadows are supported.142143# Navigation144145## Link146147Use `<Link href="/path" />` from 'expo-router' for navigation between routes.148149```tsx150import { Link } from 'expo-router';151152// Basic link153<Link href="/path" />154155// Wrapping custom components156<Link href="/path" asChild>157<Pressable>...</Pressable>158</Link>159```160161Whenever possible, include a `<Link.Preview>` to follow iOS conventions. Add context menus and previews frequently to enhance navigation.162163## Stack164165- ALWAYS use `_layout.tsx` files to define stacks166- Use Stack from 'expo-router/stack' for native navigation stacks167168### Page Title169170Set the page title in Stack.Screen options:171172```tsx173<Stack.Screen options={{ title: "Home" }} />174```175176## Context Menus177178Add long press context menus to Link components:179180```tsx181import { Link } from "expo-router";182183<Link href="/settings" asChild>184<Link.Trigger>185<Pressable>186<Card />187</Pressable>188</Link.Trigger>189<Link.Menu>190<Link.MenuAction191title="Share"192icon="square.and.arrow.up"193onPress={handleSharePress}194/>195<Link.MenuAction196title="Block"197icon="nosign"198destructive199onPress={handleBlockPress}200/>201<Link.Menu title="More" icon="ellipsis">202<Link.MenuAction title="Copy" icon="doc.on.doc" onPress={() => {}} />203<Link.MenuAction204title="Delete"205icon="trash"206destructive207onPress={() => {}}208/>209</Link.Menu>210</Link.Menu>211</Link>;212```213214## Link Previews215216Use link previews frequently to enhance navigation:217218```tsx219<Link href="/settings">220<Link.Trigger>221<Pressable>222<Card />223</Pressable>224</Link.Trigger>225<Link.Preview />226</Link>227```228229Link preview can be used with context menus.230231## Modal232233Present a screen as a modal:234235```tsx236<Stack.Screen name="modal" options={{ presentation: "modal" }} />237```238239Prefer this to building a custom modal component.240241## Sheet242243Present a screen as a dynamic form sheet:244245```tsx246<Stack.Screen247name="sheet"248options={{249presentation: "formSheet",250sheetGrabberVisible: true,251sheetAllowedDetents: [0.5, 1.0],252contentStyle: { backgroundColor: "transparent" },253}}254/>255```256257- Using `contentStyle: { backgroundColor: "transparent" }` makes the background liquid glass on iOS 26+.258259## Common route structure260261A standard app layout with tabs and stacks inside each tab:262263```264app/265_layout.tsx — <NativeTabs />266(index,search)/267_layout.tsx — <Stack />268index.tsx — Main list269search.tsx — Search view270```271272```tsx273// app/_layout.tsx274import { NativeTabs, Icon, Label } from "expo-router/unstable-native-tabs";275import { Theme } from "../components/theme";276277export default function Layout() {278return (279<Theme>280<NativeTabs>281<NativeTabs.Trigger name="(index)">282<Icon sf="list.dash" />283<Label>Items</Label>284</NativeTabs.Trigger>285<NativeTabs.Trigger name="(search)" role="search" />286</NativeTabs>287</Theme>288);289}290```291292Create a shared group route so both tabs can push common screens:293294```tsx295// app/(index,search)/_layout.tsx296import { Stack } from "expo-router/stack";297import { PlatformColor } from "react-native";298299export default function Layout({ segment }) {300const screen = segment.match(/\((.*)\)/)?.[1]!;301const titles: Record<string, string> = { index: "Items", search: "Search" };302303return (304<Stack305screenOptions={{306headerTransparent: true,307headerShadowVisible: false,308headerLargeTitleShadowVisible: false,309headerLargeStyle: { backgroundColor: "transparent" },310headerTitleStyle: { color: PlatformColor("label") },311headerLargeTitle: true,312headerBlurEffect: "none",313headerBackButtonDisplayMode: "minimal",314}}315>316<Stack.Screen name={screen} options={{ title: titles[screen] }} />317<Stack.Screen name="i/[id]" options={{ headerLargeTitle: false }} />318</Stack>319);320}321```322