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
:alert: This `rc` version requires `@nativescript/[email protected].*` to work properly.
4
+
3
5
Makes using [Tailwind CSS](https://tailwindcss.com/) in NativeScript a whole lot easier!
4
6
5
7
```html
@@ -11,34 +13,23 @@ Makes using [Tailwind CSS](https://tailwindcss.com/) in NativeScript a whole lot
11
13
12
14

13
15
14
-
# Usage (with @nativescript/webpack version 5.x)
16
+
# Usage
17
+
18
+
> **Note:** This guide assumes you are using `@nativescript/[email protected]` as some configuration is done automatically. If you have not upgraded yet, please read the docs below for usage with older `@nativescript/webpack` versions.
15
19
16
20
Install `@nativescript/tailwind` and `tailwindcss`
Change your `app.css` or `app.scss` to include the tailwind utilities
23
-
24
-
```css
25
-
@tailwind components;
26
-
@tailwind utilities;
27
-
```
26
+
Generate a `tailwind.config.js` with
28
27
29
-
Start using tailwind.
30
-
31
-
# Using Tailwind CSS JIT (just in time)
32
-
33
-
Tailwind's new jit mode is supported, it just has to be enabled in the config. See https://tailwindcss.com/docs/just-in-time-mode#enabling-jit-mode for details.
34
-
35
-
To generate a blank config, you can run
36
-
37
-
```bash
28
+
```cli
38
29
npx tailwindcss init
39
30
```
40
31
41
-
Example config with `jit` enabled:
32
+
Adjust `content`, `darkMode`, `corePlugins` plus any other settings you need, here are the values we recommend:
42
33
43
34
```js
44
35
// tailwind.config.js
@@ -47,18 +38,29 @@ module.exports = {
47
38
content: [
48
39
'./app/**/*.{css,xml,html,vue,svelte,ts,tsx}'
49
40
],
50
-
darkMode:false, // or 'media' or 'class'
41
+
// use .dark to toggle dark mode - since 'media' (default) does not work in NativeScript
Change your `app.css` or `app.scss` to include the tailwind utilities
54
+
55
+
```css
56
+
@tailwind base;
57
+
@tailwind components;
58
+
@tailwind utilities;
59
+
```
60
+
61
+
Start using tailwind in your app.
62
+
63
+
# Using a custom PostCSS config
62
64
63
65
In case you need to customize the postcss configuration, you can create a `postcss.config.js` (other formats are supported, see https://github.com/webpack-contrib/postcss-loader#config-files) file and add any customizations, for example:
64
66
@@ -75,94 +77,91 @@ module.exports = {
75
77
76
78
> **Note:** if you want to apply customizations to `tailwindcss` or `@nativescript/tailwind`, you will need to disable autoloading:
77
79
>
78
-
> ```bash
80
+
> ```cli
79
81
> ns config set tailwind.autoload false
80
82
> ```
81
83
> This is required only if you make changes to either of the 2 plugins - because by default `postcss-loader` processes the config file first, and then the `postcssOptions` passed to it. With autoloading enabled, any customizations will be overwritten due to the loading order. Setting `tailwind.autoload` to `false` just disables the internal loading of these plugins, and requires you to manually add them to your postcss config in the above order.
82
84
83
-
84
-
## Usage (with @nativescript/webpack version <5.x)
85
+
## Usage with older @nativescript/webpack versions
85
86
86
87
This usage is considered legacy and will not be supported - however we are documenting it here in case your project is still using older `@nativescript/webpack`.
> **Note:** make sure you only include this once (for example in `App.vue`) - otherwise your bundle will contain the whole tailwind.css file multiple times.
166
-
165
+
**Make sure you append `postcss-loader` to all css/scss rules in the config.**
0 commit comments