Back to Tamagui

Native UI

code/tamagui.dev/data/docs/components/native/2.0.0.mdx

1.144.43.0 KB
Original Source

Native Integrations

Tamagui components work great out of the box, but several offer optional native integrations for improved performance and platform-native UX. All native integrations are opt-in - components work without them, just with slightly different behavior.

@tamagui/native Package

The @tamagui/native package provides setup utilities for native integrations. Import the setup modules at your app's entry point, before any Tamagui imports.

bash
npm install @tamagui/native

Portal

Native portals preserve React context - the default implementation on native uses a JS-based approach that breaks React context, or requires you to hoist data awkwardly. With native portals, your custom contexts (navigation, app state) work inside Sheet, Dialog, Popover, and other portaled content.

Setup

bash
npm install react-native-teleport
tsx
// App.tsx - before any Tamagui imports
import '@tamagui/native/setup-teleport'

See Portal docs for full details.

Sheet Gestures

Native gesture coordination - makes sheets feel smoother and not get confused with scrollable content during drags. Without this, scroll and pan gestures can occasionally conflict on iOS.

Setup

bash
npm install react-native-gesture-handler
tsx
// App.tsx - before any Tamagui imports
import '@tamagui/native/setup-gesture-handler'
import { GestureHandlerRootView } from 'react-native-gesture-handler'

export default function App() {
  return (
    <GestureHandlerRootView style={{ flex: 1 }}></GestureHandlerRootView>
  )
}

See Sheet docs for full details.

Native menus - renders platform-native context menus instead of custom overlays. Uses iOS's native menu API for haptics, blur effects, and system integration.

Setup

bash
npm install zeego @react-native-menu/menu react-native-ios-context-menu react-native-ios-utilities sf-symbols-typescript
tsx
// App.tsx - before any Tamagui imports
import '@tamagui/native/setup-zeego'

Then use the native prop:

tsx
<Menu native></Menu>

See Menu docs and ContextMenu docs for full details.

Toast

Native toasts - uses platform-native toast implementations:

  • iOS: SPIndicator (system-style indicators)
  • Android: ToastAndroid
  • Web: Notification API

Setup

bash
npm install burnt
tsx
// App.tsx - before any Tamagui imports
import '@tamagui/native/setup-burnt'

Then use the native prop on ToastProvider:

tsx
<Toast.Provider native></Toast.Provider>

See Toast docs for full details.

LinearGradient

Native gradients - uses expo-linear-gradient for high-performance native gradient rendering.

Setup

bash
npm install expo-linear-gradient
tsx
// App.tsx - before any Tamagui imports
import '@tamagui/native/setup-expo-linear-gradient'

See LinearGradient docs for full details.