expo-style-bridge is a style transformation library that automatically converts React Native StyleSheet properties into native SwiftUI modifiers (iOS) and Jetpack Compose modifiers (Android). Perfect for developers building cross-platform apps with Expo who need to integrate native UI components while maintaining consistent styling.
- 🔄 Seamless conversion from React Native styles to native platform modifiers
- 📱 Cross-platform support for iOS (SwiftUI) and Android (Jetpack Compose)
- 🎨 Type-safe styling with full TypeScript support
- ⚡ Zero runtime overhead - compile-time transformations
- 🧩 Modular architecture - use only what you need
- 🔧 Extensible - easily add custom style converters
import { convertToSwiftUIModifiers } from 'expo-style-bridge';
import { Button } from '@expo/ui/swift-ui';
const style = {
padding: 16,
opacity: 0.8,
zIndex: 10,
display: 'none',
overflow: 'hidden'
};
const modifiers = convertToSwiftUIModifiers(style); // modifiers is an array
// Use the modifiers with a SwiftUI component
<Button modifiers={modifiers}>
Click me
</Button>Install via npm, yarn, or pnpm:
npm install expo-style-bridge
# or
yarn add expo-style-bridge
# or
pnpm add expo-style-bridgeTransform React Native StyleSheet properties into native platform equivalents:
- Padding:
padding,paddingHorizontal,paddingVertical,paddingTop,paddingBottom,paddingLeft,paddingRight→ SwiftUI.padding() - Opacity:
opacity→ SwiftUI.opacity() - Layout:
zIndex→ SwiftUI.zIndex() - Visibility:
display→ SwiftUI.hidden() - Clipping:
overflow→ SwiftUI.clipped() - Colors:
backgroundColor,color→ SwiftUI.background()/.foregroundColor()
Upcoming style property support:
- Gradients
- Border styling (width, radius, color)
- Shadow and elevation
- Transforms (rotate, scale, translate)
- Flexbox layout properties
- Jetpack compose
src/
├── index.ts # Main converter with reducer pattern
├── types.ts # TypeScript type definitions
└── mappers/ # Individual style converters
├── padding/
├── opacity/
├── zIndex/
├── hidden/
└── clipped/
Each mapper is a self-contained converter with tests. To add a new converter:
- Create a folder in
src/mappers/ - Implement the converter function
- Add tests
- Integrate into the reducer chain in
src/index.ts
- Expo Native Modules: Integrate custom native UI components with React Native styling
- Hybrid Apps: Build apps that mix React Native and native views seamlessly
- Migration Projects: Gradually migrate from React Native to native platforms
- Design Systems: Maintain consistent styling across React Native and native components
- Performance Optimization: Leverage native rendering while keeping React Native DX
@expo/ui>= 0.2.0-beta.7react-native>= 0.82.0- TypeScript >= 4.0 (recommended)
- @expo/ui - Expo's native UI component library
- React Native - Build native apps using React
- Expo - Framework for universal React applications
Contributions are welcome! Please read our contributing guidelines and submit PRs for new style converters or improvements.
MIT © LabLamb