Get up and running with @mgcrea/react-native-tailwind in 3 minutes!
npm install @mgcrea/react-native-tailwindmodule.exports = {
presets: ['module:@react-native/babel-preset'],
plugins: [
'@mgcrea/react-native-tailwind/babel', // ← Add this
],
};In your App.tsx (or any file using className):
import '@mgcrea/react-native-tailwind/src/react-native';
import { View, Text } from 'react-native';export function App() {
return (
<View className="flex-1 bg-gray-100 p-4">
<Text className="text-2xl font-bold text-blue-500 mb-4">
Hello Tailwind!
</Text>
<View className="bg-white rounded-lg p-6">
<Text className="text-base text-gray-700">
This is compiled at build time with zero runtime overhead!
</Text>
</View>
</View>
);
}The Babel plugin transforms your code from this:
<View className="m-4 p-2 bg-blue-500" />To this at compile-time:
<View style={styles._bg_blue_500_m_4_p_2} />
const styles = StyleSheet.create({
_bg_blue_500_m_4_p_2: {
margin: 16,
padding: 8,
backgroundColor: '#3B82F6',
},
});className="flex-1 flex-row items-center justify-between"className="m-4 px-6 py-3"className="bg-blue-500 text-white border border-gray-200"className="text-xl font-bold text-center"className="border-2 border-gray-300 rounded-lg"- 📖 Full Documentation
- 💬 GitHub Issues
- 🎯 See the example app for a complete working example
- Clear Metro cache:
npx react-native start --reset-cache - Run your app:
npx react-native run-iosornpx react-native run-android - Check the README for the full list of supported classes
Happy coding! 🎉