All Projects → OwenMelbz → babel-plugin-tailwind-rn

OwenMelbz / babel-plugin-tailwind-rn

Licence: other
Allows you to use className="w-full md:w-1/2" syntax in your react native projects.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to babel-plugin-tailwind-rn

Babel Plugin Macros
🎣 Allows you to build simple compile-time libraries
Stars: ✭ 2,366 (+7532.26%)
Mutual labels:  babel-plugin
ttall
Laravel fronend preset for TTALL stack - Tailwindcss | Turbolinks | Alpine.js | Laravel | Livewire 🚀
Stars: ✭ 50 (+61.29%)
Mutual labels:  tailwind
loopple
Drag & drop dashboard builder
Stars: ✭ 180 (+480.65%)
Mutual labels:  tailwind
Eslint Import Resolver Babel Module
Custom eslint resolve for babel-plugin-module-resolver
Stars: ✭ 236 (+661.29%)
Mutual labels:  babel-plugin
tailwind
Makes using TailwindCSS in NativeScript a whole lot easier!
Stars: ✭ 128 (+312.9%)
Mutual labels:  tailwind
github-markdown-tailwindcss
⛵ Replicate GitHub Flavored Markdown with Tailwind CSS components
Stars: ✭ 100 (+222.58%)
Mutual labels:  tailwind
Param.macro
Partial application syntax and lambda parameters for JavaScript, inspired by Scala's `_` & Kotlin's `it`
Stars: ✭ 170 (+448.39%)
Mutual labels:  babel-plugin
x-blade-components
Laravel Blade Components ready to use
Stars: ✭ 36 (+16.13%)
Mutual labels:  tailwind
tailwind-dashboard-template
Mosaic Lite is a free admin dashboard template built on top of Tailwind CSS and fully coded in React. Made by
Stars: ✭ 1,662 (+5261.29%)
Mutual labels:  tailwind
rebuild-x-with-tailwind
My playground to learn Tailwind CSS
Stars: ✭ 29 (-6.45%)
Mutual labels:  tailwind
Xwind
Tailwind CSS as a templating language in JS and CSS-in-JS
Stars: ✭ 249 (+703.23%)
Mutual labels:  babel-plugin
tailwind-components
Collection of components found on the internet
Stars: ✭ 1,326 (+4177.42%)
Mutual labels:  tailwind
powergrid-demo
⚡ PowerGrid fully configured in a Laravel project.
Stars: ✭ 38 (+22.58%)
Mutual labels:  tailwind
Babel Plugin React Intl Auto
i18n for the component age. Auto management react-intl ID.
Stars: ✭ 203 (+554.84%)
Mutual labels:  babel-plugin
tailwindcss-fluid
Fluid utilities for Tailwind CSS
Stars: ✭ 112 (+261.29%)
Mutual labels:  tailwind
Emotion
👩‍🎤 CSS-in-JS library designed for high performance style composition
Stars: ✭ 14,177 (+45632.26%)
Mutual labels:  babel-plugin
laravel-tvi
A CMS/CRM for creating & managing websites and form leads. Using Laravel, Tailwind CSS, Vue, and Inertia JS
Stars: ✭ 36 (+16.13%)
Mutual labels:  tailwind
covid-19-stats
Get the latest COVID-19 statistics by country
Stars: ✭ 41 (+32.26%)
Mutual labels:  tailwind
nuro.dev
🌿 Personal Portfolio
Stars: ✭ 260 (+738.71%)
Mutual labels:  tailwind
svelte-pwa-now
A PWA ready Svelte v3.0 starter template with Tailwind, Now integration and optional Typescript suppot
Stars: ✭ 138 (+345.16%)
Mutual labels:  tailwind

React Native Tailwind CSS v2

When a babel plugin, and react hook has a baby. You end up with this! A way that allows you to use Tailwind CSS within your React Native project via the familiar className property!

screenshot

Changes since v1

The architecture around v1 focused on using hooks within each component, however React doesn't support a dynamic number of hooks, which means if the number or rows, views etc changed it would throw an error.

The internals for the react side of v2 have been changed to an HOC which stores the state only once, then passes it down to each component by wrapping your layout level component (often the App) with our useTailwind function.

Installation

  • yarn add babel-plugin-tailwind-rn

  • babel.config.js add the plugin tailwind-rn e.g. plugins: ['tailwind-rn']

Usage

When Metro/Webpack boots up, it runs your apps javascript through babel.

We hook into this process converting your className="text-xl" props into style={useTailwind("text-xl")}

This means we're able to add listeners on the resize events and dynamically update your styles based off the responsive Tailwind classes.

To provide your components with the correct classes, you'll need to wrap your App with our HOC, this is your root-most component.

import useTailwind from 'babel-plugin-tailwind-rn/dist/useTailwind'

function App() {
    return <Text>My Tailwind App!</Text>
}

export default useTailwind(App)

Then use the normal react syntax!

function App() {
    return <Text className="text-md lg:text-xl">My Tailwind App!</Text>
}

Important Notes

Updating Config

Metro uses heavy caching to speed up your builds, this means it holds your tailwind config in memory on the device/simulator.

Once you've made changes to your tailwind.config.js You need to clear the metro cache, often with shift + r which reloads with fresh cache.

However that only refreshes the webpack cache, you now need to exit the RN app on the simulator/device, and then relaunch the app. Metro allows you to push i or a to launch it again.

Example Project

You can download an example project which uses Expo to see how it works

https://github.com/OwenMelbz/tailwind-rn-example

Disclaimer

Code heavily influenced from: https://github.com/vadimdemedes/tailwind-rn as well as some glorious copy/paste of the class validation utilities!

Also thanks to Brad from Discord... I don't know who you are, or where you came from. But thanks for Babel support!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].