Overview
Uniwind provides built-in platform selectors that allow you to apply styles conditionally based on the platform your app is running on. This is essential for creating platform-specific user experiences in React Native.Platform selectors are resolved at runtime and automatically apply the correct styles for the current platform.
Basic Usage
Use platform selectors directly in yourclassName
prop with the syntax platform:utility
:
Why Use Platform Selectors?
Platform selectors are superior to React Native’sPlatform.select()
API for several reasons:
❌ Not Recommended: Platform.select()
- Requires importing
Platform
API - More verbose syntax
- Cannot combine with other utilities easily
- Less readable when multiple platform conditions are needed
✅ Recommended: Platform Selectors
- Clean, declarative syntax
- No extra imports needed
- Easy to combine with other Tailwind utilities
- Better readability and maintainability
- Works seamlessly with theme variants
Supported Platforms
Targets iOS devices (iPhone, iPad). Styles are applied only when running on iOS.
Targets Android devices. Styles are applied only when running on Android.
Targets web browsers. Styles are applied only when running in a web environment (e.g., React Native Web).