You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -107,7 +111,7 @@ Add babel-plugin-macros to your `.babelrc` or `babel.config.js` and you're all s
107
111
108
112
### Using the `tw` prop
109
113
110
-
The best and easiest usage is to simply use the `tw` prop that is artificially added to all JSX elements. Under the hood, the macro removes the `tw` prop completely and instead applies or extends a `style` prop and also adds a web-only media id used by [react-native-media-query](https://github.com/kasinskas/react-native-media-query) to apply CSS-based media queries.
114
+
The best and easiest usage is to simply use the `tw` prop that is artificially added to all JSX elements. Under the hood, the macro removes the `tw` prop completely and instead applies or extends a `style` prop and also adds a web-only data-tw id used to apply CSS-based media queries.
111
115
112
116
All you have to do is have _any_ import of react-native-tailwind.macro in your file, either `import "react-native-tailwind.macro"` or `import { /* whatever import you need */ } from "react-native-tailwind.macro"`.
By default, the device's color scheme preference is used to enable dark mode. If you want to dynamically change whether dark mode is enabled, you can wrap your App with `TailwindProvider` and pass in your dark mode preference.
230
234
235
+
On the web, the set value will automatically be persisted in a cookie to enable SSR and SSG without flashes on load.
getInitialColorScheme() // returns "light" or "dark"
258
+
```
259
+
245
260
### Macro Options
246
261
247
262
You can apply options to the macro by adding a `babel-plugin-macros.config.js` or specifying them in your `package.json` like below:
@@ -282,9 +297,10 @@ Alternatively:
282
297
283
298
In order to enable SSR support via media queries on Next.js, update your [custom document](https://nextjs.org/docs/advanced-features/custom-document) as follows:
// Apply media id for CSS-based media queries using react-native-media-query
363
-
dataSet={{ media: tailwindStyles["a7gsbs"].id }}
388
+
// Apply data-tw id for CSS-based media queries
389
+
dataSet={{ tw: tailwindStyles["a7gsbs"].id }}
364
390
/>
365
391
)
366
392
}
@@ -380,7 +406,7 @@ For more examples and use cases, check the [macro test snapshots](packages/react
380
406
381
407
-[tailwind-react-native-classnames](https://github.com/jaredh159/tailwind-react-native-classnames): Used for compiling Tailwind styles
382
408
383
-
-[react-native-media-query](https://github.com/kasinskas/react-native-media-query): Used for applying responsive styles with CSS media queries on the web
409
+
-[react-native-media-query](https://github.com/kasinskas/react-native-media-query): Provides the base implementation used to enable CSS media query support
384
410
385
411
-[twin.macro](https://github.com/ben-rogerson/twin.macro): Inspiration for writing a babel macro
0 commit comments