npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@mgcrea/react-native-tailwind

v0.15.1

Published

Compile-time Tailwind CSS for React Native with zero runtime overhead

Downloads

2,256

Readme

Overview

Compile-time Tailwind CSS for React Native with zero runtime overhead. Transform className props to optimized StyleSheet.create calls at build time using a Babel plugin.

Features

  • ⚡ Zero Runtime Overhead - All transformations happen at compile time
  • 🔧 No Dependencies - Direct-to-React-Native style generation without tailwindcss package
  • 🎯 Babel-only Setup - No Metro configuration required
  • 📝 TypeScript-first - Full type safety and autocomplete support
  • 🚀 Optimized Performance - Compiles down to StyleSheet.create for optimal performance
  • 🔀 Dynamic className - Conditional styles support with compile-time optimization
  • 📦 Small Bundle Size - Only includes actual styles used in your app
  • 🎯 State Modifiers - active:, hover:, focus:, and disabled: modifiers for interactive components
  • 📱 Platform Modifiers - ios:, android:, and web: modifiers for platform-specific styling
  • 🌓 Color Scheme Modifiers - dark: and light: and scheme: modifiers for automatic theme adaptation
  • 🎨 Custom Colors - Extend the default palette via tailwind.config.*
  • 📐 Arbitrary Values - Use custom sizes and borders: w-[123px], rounded-[20px]
  • 📜 Special Style Props - Support for contentContainerClassName, columnWrapperClassName, and more

📊 How It Compares - See how this library stacks up against other React Native styling solutions.

Demo

demo

Quick Start

Installation

npm install @mgcrea/react-native-tailwind
# or
yarn add @mgcrea/react-native-tailwind
# or
pnpm add @mgcrea/react-native-tailwind

1. Add Babel Plugin

Update your babel.config.js:

module.exports = {
  presets: ["module:@react-native/babel-preset"],
  plugins: [
    "@mgcrea/react-native-tailwind/babel", // Add this line
  ],
};

2. Enable TypeScript Support (Optional)

Create a type declaration file to enable className prop autocomplete:

// src/types/react-native-tailwind.d.ts
import "@mgcrea/react-native-tailwind/react-native";

3. Start Using className

import { View, Text } from "react-native";

export function MyComponent() {
  return (
    <View className="flex-1 bg-gray-100 p-4">
      <Text className="text-xl font-bold text-blue-500">Hello, Tailwind!</Text>
    </View>
  );
}

How It Works

The Babel plugin transforms your code at compile time:

Input (what you write):

<View className={`rounded-lg p-4 ${isSelected ? "bg-blue-500 border border-blue-700" : "bg-gray-200"}`} />

Output (what Babel generates):

import { StyleSheet } from "react-native";

<View
  style={[
    _twStyles._rounded_lg,
    _twStyles._p_4,
    isSelected ? _twStyles._bg_blue_500_border_border_blue_700 : _twStyles._bg_gray_200,
  ]}
/>;

const _twStyles = StyleSheet.create({
  _rounded_lg: { borderRadius: 8 },
  _p_4: { padding: 16 },
  _bg_blue_500_border_border_blue_700: { backgroundColor: "#3B82F6", borderWidth: 1, borderColor: "#1D4ED8" },
  _bg_gray_200: { backgroundColor: "#E5E7EB" },
});

Documentation

📚 Full Documentation

Examples

Dynamic Styles

import { useState } from "react";
import { Pressable, Text } from "react-native";

export function ToggleButton() {
  const [isActive, setIsActive] = useState(false);

  return (
    <Pressable
      onPress={() => setIsActive(!isActive)}
      className={isActive ? "bg-green-500 p-4" : "bg-red-500 p-4"}
    >
      <Text className="text-white">{isActive ? "Active" : "Inactive"}</Text>
    </Pressable>
  );
}

State Modifiers

import { Pressable, Text } from "@mgcrea/react-native-tailwind";

export function MyButton() {
  return (
    <Pressable className="bg-blue-500 active:bg-blue-700 p-4 rounded-lg">
      <Text className="text-white font-semibold">Press Me</Text>
    </Pressable>
  );
}

Dark Mode

import { View, Text } from "react-native";

export function ThemeCard() {
  return (
    <View className="bg-white dark:bg-gray-900 p-4 rounded-lg">
      <Text className="text-gray-900 dark:text-white">Adapts to device theme</Text>
    </View>
  );
}

Platform-Specific Styles

import { View, Text } from "react-native";

export function PlatformCard() {
  return (
    <View className="p-4 ios:p-6 android:p-8 bg-white rounded-lg">
      <Text className="text-base ios:text-blue-600 android:text-green-600">Platform-specific styles</Text>
    </View>
  );
}

Contributing

Contributions are welcome! Please read our Contributing Guide for details.

Credits

  • Tailwind CSS - The utility-first CSS framework that revolutionized the way we style applications. If you enjoy this library, consider supporting them by purchasing Tailwind Plus.

Authors

MIT License

Copyright (c) 2025 Olivier Louvignes <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.