Skip to content

Standalone Components

Standalone components are native SwiftUI components that can be used independently, outside of the SwiftUI tree container. They provide direct access to native functionality with imperative APIs.

Use standalone components when you need:

  • Direct native rendering without the SwiftUI tree overhead
  • Imperative control with ref handles (show/dismiss)
  • Integration with existing React Native views
  • SF Symbols anywhere in your app
ComponentDescription
SFSymbolApple SF Symbols with full customization
SwiftUIPickerNative picker with imperative control
SwiftUISheetModal sheet with programmatic presentation
SwiftUISheetPickerSearchable picker in a sheet
import { SFSymbol, SwiftUISheet } from '@mgcrea/react-native-swiftui';
// Can be used anywhere in your React Native app
<View style={styles.container}>
<SFSymbol name="star.fill" size={24} color="gold" />
<SwiftUISheet
isPresented={showSheet}
title="My Sheet"
onDismiss={() => setShowSheet(false)}
/>
</View>
import { SwiftUI } from '@mgcrea/react-native-swiftui';
// Must be inside SwiftUI root container
<SwiftUI style={{ flex: 1 }}>
<SwiftUI.Form>
<SwiftUI.Section>
<SwiftUI.TextField label="Name" text={name} onChange={setName} />
</SwiftUI.Section>
</SwiftUI.Form>
</SwiftUI>

Standalone components support ref-based imperative APIs:

import { SwiftUISheet, SwiftUISheetHandle } from '@mgcrea/react-native-swiftui';
import { useRef } from 'react';
function MyComponent() {
const sheetRef = useRef<SwiftUISheetHandle>(null);
const showSheet = () => {
sheetRef.current?.present();
};
const hideSheet = () => {
sheetRef.current?.dismiss();
};
return (
<>
<Button title="Show" onPress={showSheet} />
<SwiftUISheet
ref={sheetRef}
title="My Sheet"
onDismiss={() => console.log('dismissed')}
/>
</>
);
}

Standalone components are exported directly from the package:

import {
SFSymbol,
SwiftUIPicker,
SwiftUISheet,
SwiftUISheetPicker,
} from '@mgcrea/react-native-swiftui';
FeatureStandaloneTree Components
Requires SwiftUI containerNoYes
Imperative API (ref)YesNo
Works with RN viewsYesNo
Full SwiftUI stylingLimitedYes
Forms integrationNoYes
Use caseIsolated widgetsFull SwiftUI layouts

Use Standalone when:

  • You need an SF Symbol icon anywhere
  • You want a simple sheet/picker without building a full SwiftUI form
  • You’re integrating with existing React Native components
  • You need programmatic show/hide control

Use Tree Components when:

  • Building complete forms with native iOS styling
  • You want the full SwiftUI component library
  • Components need to interact (form validation, sections, etc.)
  • You’re building a primarily SwiftUI-based screen